How could I count the elements of each dimension of an array?
| From: | orlandopozo at icnet dot com dot ve | Date: | Mon, 15 Dec 2003 01:07:06 +0000 |
| Subject: | How could I count the elements of each dimension of an array? | ||
| Groups: | php.general | ||
| Request: | Send a blank email to php-general+get-172699@lists.php.net to get a copy of this message | ||
How could I count the elements of each dimension of an array?
I have this script, but it failed, thanks for any help
<?
$ojpp[0] = "1";
$ojpp[1] = "2";
$ojpp[2] = "3";
$ojpp[3] = "4";
$ojpp[0][1] = "1";
$ojpp[0][2] = "2";
$ojpp[0][3] = "3";
$ojpp[0][0][1] = "1";
$ojpp[0][0][2] = "2";
$test1 = count($ojpp); // first dimension
$test2 = count($ojpp[0]); // second dimension
$test3 = count($ojpp[0][0]); // third dimension
echo $test1;
echo $test2;
echo $test3;
echo "<pre>";
print_r($ojpp);
echo "</pre>";
?>