:::

20. array_push()/*Arry function*/

Aside from the array() function itself,array_push() is arguably the most common and useful function for manipulating arrays.

array_push() takes two arguments: an array, and an element to add to the end of that array. Here's an example:

$fav_bands = array();
array_push($fav_bands, "Maroon 5");
array_push($fav_bands, "Bruno Mars");
array_push($fav_bands, "Nickelback");
array_push($fav_bands, "Katy Perry");
array_push($fav_bands, "Macklemore");

Another cool array function is count(). Passing an array to count() will return the number of elements in that array. Like this:

print count($fav_bands); // prints 5

:::

語系選擇