PHP: Array count

This entry is part 21 of 54 in the series PHP Tutorial

To get the no of elements in an array, we can use the count function.

Here we pass the $gift array into the count function.

$gift = array("TV","car","aeroplane", "iPad", "iPhone", "PS4"); 

$gift_count = count($gift);
echo "I have $gift_count gifts.";


Series Navigation<< PHP: Array
PHP: Sorting an array >>