|
|
|
||||
|
Welcome to the GoFuckYourself.com - Adult Webmaster Forum forums. You are currently viewing our boards as a guest which gives you limited access to view most discussions and access our other features. By joining our free community you will have access to post topics, communicate privately with other members (PM), respond to polls, upload content and access many other special features. Registration is fast, simple and absolutely free so please, join our community today! If you have any problems with the registration process or your account login, please contact us. |
![]() |
|
|||||||
| Discuss what's fucking going on, and which programs are best and worst. One-time "program" announcements from "established" webmasters are allowed. |
|
|
Thread Tools |
|
|
#1 |
|
Snow's Parole Officer
Join Date: Sep 2001
Location: mud hut next to Bin Laden's
Posts: 1,161
|
PHP Question
Soul...you out there...this is an easy one I think...I just hate loops...
I would like to print a line...after every 5 lines... Example: how's life... how's life... how's life... how's life... how's life... JUST FINE THANKS... how's life... etc... thanks in advance |
|
|
|
|
|
#2 |
|
Confirmed User
Join Date: Oct 2001
Posts: 6,693
|
Keep a counter of how many lines you've printed and every time you print a line check the mod result of the counter.
if ($counter%5=0) { echo "This is the line to print every 5th line." } Basically if the reminder of the counter divided by 5 is 0 you want to print that line. I typed it wrong before and this probably wrong, too, but that's the general concept anyways. [This message has been edited by FATPad (edited 01-13-2002).] |
|
|
|
|
|
#3 |
|
Confirmed User
Join Date: Oct 2001
Posts: 6,693
|
Holy fucken christ am I an idiot now. I shouldn't be near a keyboard.
[This message has been edited by FATPad (edited 01-13-2002).] |
|
|
|
|
|
#4 |
|
Confirmed User
Join Date: Oct 2001
Location: LA
Posts: 162
|
for ($i=1; $i<20; $i++)
{ echo "some text $i \n "; if (!($i % 5)) { echo "line 5"; } } NOTE u have to start with an 1 not 0 ... ------------------ ah you have been blessed with 72 virgins? |
|
|
|
|
|
#5 |
|
Confirmed User
Join Date: Oct 2001
Location: LA
Posts: 162
|
works
![]() awechen@office -- /home/awechen > ./php -q ? for ($i=1; $i<20; $i++) { echo "some text $i \n "; if (!($i % 5)) { echo "line 5\n"; } }? some text 1 some text 2 some text 3 some text 4 some text 5 line 5 some text 6 some text 7 some text 8 some text 9 some text 10 line 5 some text 11 some text 12 some text 13 some text 14 some text 15 line 5 some text 16 some text 17 some text 18 some text 19 awechen@office -- /home/awechen > ------------------ ah you have been blessed with 72 virgins? [This message has been edited by awechen (edited 01-14-2002).] |
|
|
|