How do I make a for or while loop that prints
and then another that prints and only repeats it when something is added making four | and then make a new row |
when the 4 are filled up?
2007-03-20
10:17:58
·
1 answers
·
asked by
Am
4
in
Computers & Internet
➔ Programming & Design
WTHell, that was simple?!? I'm sooo d00med!
Is "foreach" a php thingy or do I just put "for" there?
And wthell is "$x%" referring to in the example???
2007-03-20
10:41:17 ·
update #1
Eeeeeeeeek
no one else is gonna ans my Q ...
?!!?!?!?!?!!?
:-S
2007-03-20
11:05:06 ·
update #2
1 answers
$x=0;
$numTds=4;
foreach($something as $s){
if ($x%$numTds==0){print ' ';}
print ' | ';
$x++;
if ($x%$numTds==0){print ' ';}
}
The foreach is another type of loop in php and you can replace it with a for or a while loop depending on your needs.
The % in php is the modulus operator and returns the decimal value of 2 numbers being divided. so $x%4 will equal 0 when x is 4, 8, 12 ect because the result is a whole number.
2007-03-20 10:25:41
·
answer #1
·
answered by sheepbalz 3
·
0⤊
0⤋
fedest.com, questions and answers
|