Showing posts with label php array. Show all posts
Showing posts with label php array. Show all posts

Thursday, July 10, 2008

How to get the size of an array in php - Find Array Size

Following code will show you how to get the size(Element count) of a array in php using count() and sizeof() (sizeof is same as count() )


<?php

$myA[0] = 12;
$myA[1] = 8;
$myA[2] = 20;

$arr_size = count($myA);
echo $arr_size; // 3

//you can also use sizeof()
//sizeof() is a alias for count()

$arr_size2 = sizeof($myA);
echo $arr_size2; // 3

?>




Get custom programming done at GetAFreelancer.com!