Differences
This shows you the differences between two versions of the page.
amprog_04_ex1 [2017-09-01 14:54] |
amprog_04_ex1 [2022-07-18 13:20] (current) |
||
---|---|---|---|
Line 1: | Line 1: | ||
+ | ====== Exempel - While-sats i en While-sats ====== | ||
+ | |||
+ | |||
+ | <code php> | ||
+ | <?php | ||
+ | include(' | ||
+ | likadana ut utan att behöva skriva samma kod i varje fil. Ändrar man | ||
+ | dessutom i head.php ändras det på alla sidor samtidigt!*/ | ||
+ | |||
+ | //Gör en tabell som skriver ut tal 1 - 100 i en tabell med tio tal på varje rad. | ||
+ | |||
+ | $i = 0; //Tiotal | ||
+ | echo '< | ||
+ | while ($i < 10){ // Loopa $i från 0 - 9 | ||
+ | echo '< | ||
+ | $j = 1; // $j = ental | ||
+ | while ($j < 11){ // För varje värde på $i loopas $j från 1 - 10. | ||
+ | $ut = $i * 10 + $j; | ||
+ | echo '< | ||
+ | $j++; | ||
+ | } | ||
+ | echo '</ | ||
+ | $i++; | ||
+ | } | ||
+ | echo '</ | ||
+ | |||
+ | include(' | ||
+ | </ | ||
+ | |||
+ | |||