working with arrays part one


You want to work with string index arrays. Sometimes called Hashes.



PHP can handle number or string indexed arrays.

Arrays can be initialized in a number of ways. For example:

Basic array assignment and initialization, without specify numbers or strings:






Specifically assigning values to numbered elements in the names array:




Quicker way to assign values to names array:


Assigning values to a string indexed array – or hash (key and value pairs):


"joe" => "1 Marble Street",
"john" => "12 Marble Street",
"jim" => "23 Marble Street"




[tags]PHP, Arrays, PHP Coding School[/tags]


If you have found my website useful, please consider buying me a coffee below 😉

Leave a Reply

Your email address will not be published. Required fields are marked *