How do I get the count() value for an array?

thread: 3 messages  |  last: about 6 months ago  |  started: monday, february 15, 2010, 11:26 am pst


#1  |  kingwithin (San Francisco, CA) United States of America
Monday, February 15, 2010, 11:26 AM PST

How do I get the count() value for an array?

I have the following loop:

bc
foreach($this->objAllyAllies as $alliesArray
.bc

But before I enter it, I want to know what the total is, I think there is just a count method but can't find it in my generated code.

Thanks.

#2  |  Mike Ho (Sunnyvale, CA) United States of America Qcodo Administrator
Tuesday, February 16, 2010, 11:06 PM PST

you just call count on the array.

So if $this->objFooBarArray is an array, you can just call count($this->objFooBarArray) to get a count of items in that array.

#3  |  kingwithin (San Francisco, CA) United States of America
Tuesday, February 23, 2010, 9:38 PM PST

Yeah, this was actually a two-part question and I didn't get to that part in terms of looping through the array using foreach versus the i++.  Tweaking a little and will repost.



Copyright © 2005 - 2010, Quasidea Development, LLC
This open-source framework for PHP is released under the terms of The MIT License.