Count total array elements in php

The PHP function count() return the number of elements in an array.

Example

<!DOCTYPE html>
<html>
    <head>
        <title>Counting array elements in php</title>
    </head>
<body>
    <?php
    $marks = array(
                    "physics" => 35,
                    "maths" => 30,
                    "chemistry" => 39
				);
				
	
	echo count($marks);

 ?>
</body>
</html>

Output

3

Share

You may also like...