Page 1 of 1

PHP Array Boundaries

Posted: Wed Apr 25, 2007 10:13 pm
by ~
I am currently designing a sort of web IDE for development, and currently I'm facing a problem in which I don't know how to get an array boundary (i.e., the account/number of how many elements it contains) for tasks such as accounting code lines, etc.

Should I use something like foreach for counting, even when it could make processing double-slow, first for accounting the elements and then for doing whatever with them, or is there some function? I haven't found yet some function like $elements=get_array_limit($myarray) which could easily return the number of elements.

Posted: Thu Apr 26, 2007 12:53 am
by pcmattman
Try

Code: Select all

$size = sizeof( $myarray );
PHP's sizeof isn't the same as C's sizeof.

Posted: Thu May 17, 2007 3:31 pm
by B.E
do you mean a to find out how many elements in an arrary? if so try
count()
edit: just found out that sizeof() is an alias of count()

Code: Select all

$count = count($array);

Posted: Thu May 17, 2007 6:48 pm
by pcmattman
That's why I posted sizeof...