Skip to content Skip to sidebar Skip to footer

PHP get array size

Reading Time: < 1 minute

How to get array size of the php.Simply php count() and sizeof() functions get array size.

$myArray = array(0 => 'user_id', 1 => 'user_name', 2 => 'user_email');
$arraySize1 = sizeof($myArray);
   echo 'Array size using sizeof() function:'.$arraySize1;
echo '
'; $arraySize2 = count($myArray); echo 'Array size using count() function:'.$arraySize2;