How to get length of an array in PHP ?

Sharad Jaiswal
Written by Sharad Jaiswal

Posted On: Dec 07, 2018


    1 Answer Written

  •  Sharad Jaiswal
    Posted by poorna

    PHP array count

    In PHP Programming Language we can get count or the total number of elements of an array using count() function.

    count() function in PHP is used to get the length of an array.


    count(var array_variable, mode)

    Where array_variable is variable whose elements to be counted and the mode is an optional argument to specify the mode to be the use of counting recursive or normal


    $php_array= [1,10,5,38];
    echo count($php_array); // prints 4 as output.

Please Login or Register to leave a response.

Related Questions

Core PHP Interview Questions


T_PAAMAYIM_NEKUDOTAYIM is scope resolution operator used as :: (double colon) .Basically, it used to call static methods/variables of a Class...

Core PHP Interview Questions

What is the difference between == and === operator in PHP ?

In PHP == is equal operator and returns TRUE if $a is equal to $b after type juggling and === is Identical operator and return TRUE if $a is equal to $b, and they are of the same data type...