PHP Reference.
PHP Array functions.
A (hopefully useful) list of some array functions, what they do, and an example usage.
FUNCTION | DESCRIPTION | EXAMPLE |
---|---|---|
array() | Creates arrays and hashes. | $desserts = array("chocolate", "icecream"); $appliances = array("fridge" => "Kelvinator", "toaster" => "Sunbeam"); |
sizeof() | Returns the number of array elements. | sizeof($desserts); // Returns 2 in this case. |
is_array() | Test if a variable is an array. | is_array($desserts); // Returns true, since $desserts is an array. |
range() | Automatically create an array containing a range of elements | $letters = range("b", "f"); // Returns: ("b", "c", "d", "e", "f") |
array_values() | Returns an array of a hashes values. | $values = array_values($hash-array); |
array_keys() | Returns an array of a hashes keys. | $keys = array_keys($hash-array); |
array_search() | Find value in array, returns key or list number. | array_search("lookfor", $in); |
in_array() | Returns true or false if an array contains a specific value. | in_array("lookfor", $in); |
extract() | Extracts list items into matched variable/value pairs. | extract($deserts); // Returns variabes named as the hash keys. |
list() | Assigns list values to variables. | list($a, $b) = $desserts; |
This site is totally free to use, you have absolutely no moral or legal obligations to help us continue.
There are however, some costs involved in running the site.
So if this site helped you find your way,
perhaps you could consider contributing to our costs.
Whatever amount you feel this site was worth to you would be just wonderful.
Use PayPal
if you do decide to share and help us with the costs and in appreciation
for our time and attention, or alternatively buy a book from our Bookstore..
Time in Don's part of the world is: Sun, December 22, 2024 at 05:15 AM
Time in Franki's part of the world is: Sunday, December 22, 2024 at 6:15 PM
Don't worry neither one sleeps very long!
privacy policy ::
support us
:: home
:: live chat help
contact us
:: forum
::tutorials
:: bookstore
:: Site Map