11.2. Arrays
The functions in this section operate on arrays. Some of them sort the arrays; some of them help you find and retrieve values from arrays. Chapter 5 discusses arrays in depth.
array array(…)
The array function (Listing 11.19) takes a list of values separated by commas and returns an array. This is especially useful for creating one-off arrays to be passed to functions. Elements will be added to the array as if you used empty square brackets, which means they are numbered consecutively starting at zero. You may use the => operator to specify index values.
Listing 11.19. array
<?php //create an array $myArray = array( "Name"=>"Leon Atkinson", "Profession"=>array("Programmer", "Author"), "Residence"=>"Martinez, California" ); ?> |
Get Core PHP Programming, Third Edition now with the O’Reilly learning platform.
O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.