Tuesday 19 July 2016

PHP Array Functions - array() Function


In this post you can learn about PHP array() function. An Array is a variable which store multiple values in a single variable. In PHP array can be define by array() function. Array() function is used to create array variable in PHP.

There are three types of array in PHP.

1. Indexed Arrays - In this arrays, Arrays define with numeric index.


 Syntax - array(value1, value2, value3...)  


 e.g. $color = array("red", "green", "blue");  

2. Associative Arrays - In this arrays define with keys with it's values


 Syntax - array($key1 => $value1, $key2 => $value2, $key3 => $value3 ....);  



 e.g. $color = array(  
  1 => "red",  
  2 => "green",  
  3 => "blue"  
 );  

3. Multidimensional Arrays - An Arrays containing one or more arrays is called Multidimensional Arrays.


 e.g. $color = array(  
  "red"   => array("Red Item1", "Red Item2", "Red Item3, ...),  
  "green" => array("Green Item1", "Green Item2", "Green Item3, ...),  
  "blue"  => array("Blue Item1", "Blue Item2", "Blue Item3, ...)  
 );  

You can find complete discussion of PHP array() function in below of the Video Tutorial.



0 comments:

Post a Comment