Array,Array Function,Get Method,Post Method

13
What is array? An array is a special variable, which can hold more than one value at a time. Syntax: array(“string”,”string”,”string”); Example: $a=array(“hello”,”world”); echo $a[0]; echo $a[1];

Transcript of Array,Array Function,Get Method,Post Method

What is array?•An array is a special variable, which can hold more than one value at a time.Syntax:

array(“string”,”string”,”string”);Example:

$a=array(“hello”,”world”);echo $a[0];echo $a[1];

1.Numeric Array

2.Associative Array

• Numeric array is used for numeric value.

• The index can be assigned automatically (index always starts at 0), like this:

Syntax:

$array[0];

$array[1];

• Associative arrays are arrays that use named keys that you assign to them.

Syntax:array(“practical"=>“value", “name keys"=>“value",

“name keys"=>“value");

Example $a=array(“practical”=>”hello”,”practical1”=>”world”);echo $a[“practical”];echo $a[“practical1”];

1.in_array

2.is_array

3.implode

4.explode

In_array is used for check the string is available

or not in our array.

Syntax.

in_array(string name,variable name);

<?php$a=array("hello","world");if(in_array(“hello",$a)){

echo "true"."<br>";}else{

echo "false"."<br>";}

Is_array is used for check our array is array or

not.

Syntax:

is_array(variable name);

<?php$b="hello world";if(is_array($b)){echo "true"."<br>";

}else{echo "false"."<br>";

}?>

Implode is used for convert array to string.Syntax:

implode(variable name);Example:

<?php$c=array("hello","how","are","you");echo implode(" ",$c)."<br>";?>

Explode is used for convert string to array.Syntax:

explode(“first parameter”,variablename);

<?Php$d="hello how are you";$e=explode(" ",$d);Echo $e[0];Echo $e[1];?>

Get : used for get a value from form.

<form action=“” method="GET">

Name: <input type="text" name="name" /> Age: <input type="text" name="age" />

<input type="submit" /> </form>

Output: http://www.test.com/index.html?name1=value1&name2=value2

Post : used for get a value from form.

<form action=“” method=“post">

Name: <input type="text" name="name" /> Age: <input type="text" name="age" />

<input type="submit" /> </form>

Output: http://www.test.com/index.html