PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!
Moderator: General Moderators
impulse()
Forum Regular
Posts: 748 Joined: Wed Aug 09, 2006 8:36 am
Location: Staffordshire, UK
Contact:
Post
by impulse() » Mon Sep 25, 2006 6:06 pm
For example:
Code: Select all
while ($i = 0; $i > 50; $i++) {
$a[$i] = 0;
}
How would I cound the array to output 50?
Stephen,
Chris Corbyn
Breakbeat Nuttzer
Posts: 13098 Joined: Wed Mar 24, 2004 7:57 am
Location: Melbourne, Australia
Post
by Chris Corbyn » Mon Sep 25, 2006 6:09 pm
Just a thought... taking a wild stab in the dark... maybe.. hmmm:
count() ?
brendandonhue
Forum Commoner
Posts: 71 Joined: Mon Sep 25, 2006 3:21 pm
Post
by brendandonhue » Mon Sep 25, 2006 6:25 pm
I think this is what you wanted for your loop:
Code: Select all
for ($i = 0; $i < 50; $i++)
{
//Do something here
}
impulse()
Forum Regular
Posts: 748 Joined: Wed Aug 09, 2006 8:36 am
Location: Staffordshire, UK
Contact:
Post
by impulse() » Mon Sep 25, 2006 6:29 pm
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.
brendandonhue
Forum Commoner
Posts: 71 Joined: Mon Sep 25, 2006 3:21 pm
Post
by brendandonhue » Mon Sep 25, 2006 7:01 pm
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>';
}
Christopher
Site Administrator
Posts: 13596 Joined: Wed Aug 25, 2004 7:54 pm
Location: New York, NY, US
Post
by Christopher » Mon Sep 25, 2006 7:04 pm
I would recommend a good read through the manual sections on
Arrays and
Strings for the basics.
(#10850)