..


Sponsored Links

array

the function array creates an array (or vector) with keys and values. If you specify an array if you omit the key, a numeric key is generated automatically with the value increasing from 0.

The syntax is key => value. The key is optional, and can be numeric or string. If not defined, it generates a unique key with increasing numerical value from 0.
The parameter value, of course, is required.

Let's see some examples:

1) Array with keys and values






 $ A = array ("a" => "Dog", "b" => "Cat", "c" => "Rat");







 print_r ($ a);



The output of the code above will be:
 



 Array (



  



 [A] => Dog



  



 [B] => Cat



  



 [C] => Rat







 )

 
2) array without specifying keys





 $ A = array ("Dog", "Cat", "Mouse");







 print_r ($ a);



The output of the code above will be:
 



 Array (



  



 [0] => Dog



  



 [1] => Cat



  



 [2] => Rat







 )

 
For more information see also the lecture on Array of our guide to PHP .

In the same category ...
E-Learning
Linux (Course) Linux (Course)
Complete guide to open-source system. From 49 €.
MySQL (Course) MySQL (Course)
Management of open-source database. From 39 €.
PHP (Course) PHP (Course)
Full course for creating dynamic Web sites. From 49 €.
Sponsored Links