Page 1 of 1
Is there a function to count an array?
Posted: Mon Sep 25, 2006 6:06 pm
by impulse()
For example:
Code: Select all
while ($i = 0; $i > 50; $i++) {
$a[$i] = 0;
}
How would I cound the array to output 50?
Stephen,
Posted: Mon Sep 25, 2006 6:09 pm
by Chris Corbyn
Just a thought... taking a wild stab in the dark... maybe.. hmmm:
count() ?

Posted: Mon Sep 25, 2006 6:25 pm
by brendandonhue
I think this is what you wanted for your loop:
Code: Select all
for ($i = 0; $i < 50; $i++)
{
//Do something here
}
Posted: Mon Sep 25, 2006 6:29 pm
by impulse()
Yes!, I remember now! I've been messing with 'while' for the past few days so I forgot it was a for loop. Thank you.
Posted: Mon Sep 25, 2006 7:01 pm
by brendandonhue
No problem, you might want to look at both of these by the way as I'm not entirely sure which one you're trying to get.
Code: Select all
for ($i = 0; $i < 50; $i++)
{
echo $i . '<br>';
}
Code: Select all
for ($i = 0; $i <= 50; $i++)
{
echo $i . '<br>';
}
Posted: Mon Sep 25, 2006 7:04 pm
by Christopher
I would recommend a good read through the manual sections on
Arrays and
Strings for the basics.