Join the social network of Tech Nerds, increase skill rank, get work, manage projects...
 
  • sizeof() Function in PHP

    • 0
    • 0
    • 0
    • 0
    • 0
    • 0
    • 0
    • 0
    • 109
    Comment on it

    In php the sizeof() Function returns the number of elements in an array.

    Syntax

    sizeof(array,mode);
    

    The argument array specifies the array and the mode specifies whether to count multidimensional array or not the value 0 specifies do not count all elements of multidimensional arrays where as 1 specifies count all elements of multidimensional arrays.

    For example

    <?php
    $fruits=array
         (
         "apple"=>array
         (
         "Red"
         ),
         "grapes"=>array
         (
         "green"
         ),
         "orange"=>array
         (
         "orange"
         )
         );
    
    echo "Normal count: " . sizeof($fruits)."<br>";
    echo "Recursive count: " . sizeof($fruits,1);
    ?>
    

    output
    Normal count: 3
    Recursive count: 8

 0 Comment(s)

Sign In
                           OR                           
                           OR                           
Register

Sign up using

                           OR                           
Forgot Password
Fill out the form below and instructions to reset your password will be emailed to you:
Reset Password
Fill out the form below and reset your password: