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.
PHP Array Boundaries
-
- Member
- Posts: 2566
- Joined: Sun Jan 14, 2007 9:15 pm
- Libera.chat IRC: miselin
- Location: Sydney, Australia (I come from a land down under!)
- Contact:
Try
PHP's sizeof isn't the same as C's sizeof.
Code: Select all
$size = sizeof( $myarray );
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()
count()
edit: just found out that sizeof() is an alias of count()
Code: Select all
$count = count($array);
Microsoft: "let everyone run after us. We'll just INNOV~1"