Counting the Number of Elements in an Array or Properties in an Object in PHP


Use count() to determine the number of elements in an array.

Source Code

$arr = [1, 2, 3, 4, 5];
echo "Number of elements: " . count($arr);
Subscribe
Notify of
guest
0 Comments
Inline Feedbacks
View all comments