Jump to content

dont get if loop lol


redarrow

Recommended Posts

Advance thank you, i am currently doing a home virtul couse and dont understand the if statement.

example this is the if concept i thnk correct.
[code]
if(condition)
{
}
[/code]

But i have got lost here please help to exsplain the if code below brocken down, i need to no this part in deatal
for($i = 0; $i < 6; $i++)

within the for condition i = 0 ; then i less then 6 but that dont make sence to me,lol to stop the loop you use i++ meaning add one please help you can see where i am getting stuck the i<6 driving me mad , lol

please exsplain in a real baby terms sorry but getting so confused thats with book cd and internet.

[code]
<?php
for($i = 0; $i < 6; $i++){
echo $i."<br>";
}
?>
[/code]
Link to comment
Share on other sites

Basically all waht the code does is the following:

[code]<?php
for($i = 0; $i < 6; $i++){
echo $i."<br>";
}
?>[/code]
Setup a variable called [b]i[/b] and assign a value of 0.
Next we basically say [i]if $i [b]is less than[/b] 6 then increment $i by 1[/i].
The first bit of the code ($i = 0) is only executed once as each time php goes through the loop it will only execute the secound and thrid parts of the for loop.
Now everytime php loops through the loop it'll echo the current value of $i and a line break so you'll get the following result:[!--quoteo--][div class=\'quotetop\']QUOTE[/div][div class=\'quotemain\'][!--quotec--]1
2
3
4
5
6[/quote]
Hope that helps
Link to comment
Share on other sites

[!--quoteo(post=353688:date=Mar 10 2006, 07:36 PM:name=wildteen88)--][div class=\'quotetop\']QUOTE(wildteen88 @ Mar 10 2006, 07:36 PM) [snapback]353688[/snapback][/div][div class=\'quotemain\'][!--quotec--]
Basically all waht the code does is the following:

[code]<?php
for($i = 0; $i < 6; $i++){
echo $i."<br>";
}
?>[/code]
Setup a variable called [b]i[/b] and assign a value of 0.
Next we basically say [i]if $i [b]is less than[/b] 6 then increment $i by 1[/i].
The first bit of the code ($i = 0) is only executed once as each time php goes through the loop it will only execute the secound and thrid parts of the for loop.
Now everytime php loops through the loop it'll echo the current value of $i and a line break so you'll get the following result:
Hope that helps
[/quote]


to put this in english:

i starts at 0 ($i = 0) and while i is less than 6 ($i < 6) increment the value of i by 1 ($i++)
Link to comment
Share on other sites

[!--quoteo(post=353688:date=Mar 10 2006, 07:36 PM:name=wildteen88)--][div class=\'quotetop\']QUOTE(wildteen88 @ Mar 10 2006, 07:36 PM) [snapback]353688[/snapback][/div][div class=\'quotemain\'][!--quotec--]
Basically all waht the code does is the following:

[code]<?php
for($i = 0; $i < 6; $i++){
echo $i."<br>";
}
?>[/code]
Setup a variable called [b]i[/b] and assign a value of 0.
Next we basically say [i]if $i [b]is less than[/b] 6 then increment $i by 1[/i].
The first bit of the code ($i = 0) is only executed once as each time php goes through the loop it will only execute the secound and thrid parts of the for loop.
Now everytime php loops through the loop it'll echo the current value of $i and a line break so you'll get the following result:
Hope that helps
[/quote]

thank you so much how do i use it with a string meaning charecters so that man shows 6 times not a number.

thank you
Link to comment
Share on other sites

[!--quoteo(post=353690:date=Mar 10 2006, 07:43 PM:name=lessthanthree)--][div class=\'quotetop\']QUOTE(lessthanthree @ Mar 10 2006, 07:43 PM) [snapback]353690[/snapback][/div][div class=\'quotemain\'][!--quotec--]
to put this in english:

i starts at 0 ($i = 0) and while i is less than 6 ($i < 6) increment the value of i by 1 ($i++)

or you could say "increment the value of i by 1 until the value of i is 5, then stop"
[/quote]
Link to comment
Share on other sites

to put this in english:

i starts at 0 ($i = 0) and while i is less than 6 ($i < 6) increment the value of i by 1 ($i++)

or you could say "increment the value of i by 1 until the value of i is 5, then stop"


Thank you for the exsplnation in english perfect cheers.
Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.