Join the social network of Tech Nerds, increase skill rank, get work, manage projects...
 
  • How to count the value of an array in PHP

    • 0
    • 0
    • 0
    • 0
    • 0
    • 0
    • 0
    • 0
    • 127
    Comment on it

    Their is function called "array_count_values()" which will count all the values of an array.

    Lets suppose we have an array **array("A","Cat","Dog","A","Dog");** and we want to count the values of an array.

    Example :

    <!DOCTYPE html>
    <html>
    <body>
    
    <?php
    $a=array("A","Cat","Dog","A","Dog");
    print_r(array_count_values($a));
    ?>
    
    </body>
    </html>
    

    Output:

     Array ( [A] => 2 [Cat] => 1 [Dog] => 2 ) 
    

 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: