redarrow Posted March 10, 2006 Share Posted March 10, 2006 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 , lolplease exsplain in a real baby terms sorry but getting so confused thats with book cd and internet.[code]<?phpfor($i = 0; $i < 6; $i++){echo $i."<br>";}?>[/code] Quote Link to comment https://forums.phpfreaks.com/topic/4628-dont-get-if-loop-lol/ Share on other sites More sharing options...
wildteen88 Posted March 10, 2006 Share Posted March 10, 2006 Basically all waht the code does is the following:[code]<?phpfor($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--]123456[/quote]Hope that helps Quote Link to comment https://forums.phpfreaks.com/topic/4628-dont-get-if-loop-lol/#findComment-16192 Share on other sites More sharing options...
lessthanthree Posted March 10, 2006 Share Posted March 10, 2006 [!--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]<?phpfor($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++) Quote Link to comment https://forums.phpfreaks.com/topic/4628-dont-get-if-loop-lol/#findComment-16194 Share on other sites More sharing options...
redarrow Posted March 10, 2006 Author Share Posted March 10, 2006 [!--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]<?phpfor($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 Quote Link to comment https://forums.phpfreaks.com/topic/4628-dont-get-if-loop-lol/#findComment-16195 Share on other sites More sharing options...
lessthanthree Posted March 10, 2006 Share Posted March 10, 2006 [!--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] Quote Link to comment https://forums.phpfreaks.com/topic/4628-dont-get-if-loop-lol/#findComment-16196 Share on other sites More sharing options...
redarrow Posted March 10, 2006 Author Share Posted March 10, 2006 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. Quote Link to comment https://forums.phpfreaks.com/topic/4628-dont-get-if-loop-lol/#findComment-16199 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.