RE: Count columns in array
| From: | Tim Ward | Date: | Fri, 16 Feb 2001 09:28:35 +0000 |
| Subject: | RE: Count columns in array | ||
| Groups: | php.general | ||
| Request: | Send a blank email to php-general+get-40120@lists.php.net to get a copy of this message | ||
it's important to remember that what you have here is NOT a 2d array. $array
is an array, each element of which can be any sort of variable ...
e.g.
$array[1] = "fred";
$array[2] = Array();
$array[3] = 1.245;
... but then try ...
foreach ($array as $thisarray)
echo(count($thisarray) . "<br>");
... in this case count($array[2]) = 0 but count($array[1]) = 1 ... so be
careful.
Tim Ward
Senior Systems Engineer
Please refer to the following disclaimer in respect of this message:
http://www.stivesdirect.com/e-mail-disclaimer.html
> -----Original Message-----
> From: Fabian Fabela [mailto:php@vacagorda.com]
> Sent: 15 February 2001 18:33
> To: php-general@lists.php.net
> Subject: Count columns in array
>
>
> Hello,
>
> I have the array $array[x][y];
>
> if I want to know the x I use count($array);
>
> Now, How can I count the y??
>
> Thank you.
>
> Fabian Fabela
> fabian@vacagorda.com
> www.vacagorda.com
>
>