Source Code:
(back to article)
<?php // PHP program for counting all the elements // or values inside an array // Use of sizeof() function $array = ["W3docs1", "W3docs2", "W3docs3", "1", "2", "3"]; echo "Count second array elements: " . sizeof($array) . "\n"; $array = [ 'names' => ["W3docs1", "W3docs2", "W3docs3"], 'rank' => ['1', '2', '3'], ]; echo "Recursive count: " . sizeof($array, 1) . "\n"; echo "Normal count: " . sizeof($array, 0) . "\n"; ?>
Result:
Report an issue