This may come as a bit of a shock to you, but PHP's arrayfunctions can do a lot more than just count the elements of an array oriterate through key-value pairs. This article takes an in-depth look atPHP's less well-known array manipulation tools, illustrating how they canbe used to write tighter, more efficient code...and have some fun in thebargain as well!
The same goes for non-numeric keys - adding a new key to the
$movies["horror"] = "The Sixth Sense";
alters it to read:
$movies = array("romance" => "Moulin Rouge", "epic" => "Gladiator",
"action" => "The Terminator", "horror" => "The Sixth Sense");
In order to modify an element of an array, you would simply
assign a new value to the corresponding scalar variable. If you wanted to replace "chocolate fudge cake" with "chocolate chip cookies", you'd simply use
If it walks like an array, talks like an array and looks like
an array, it must be an array...right? Well, you can always verify your suspicions with the is_array() function, which comes in handy if you need to test whether a particular variable is an array or not.