PHP Program to get the length of the array (Using the count() function)

bookmark

<?php
    //Create a hobbies array
    $hobbies = array('Painting', 'Coding', 'Gaming', 'Browsing');

    //Get the number of elements in hobbies array
    $hobby_count = count($hobbies);

    //Display the hobbies count
    echo $hobby_count; // Output: 4
?>

 

Output
4