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

bookmark

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

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

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

 

Output
4