php - How to output a variable after each loop? -
before writing did research. first-ever code did in php. did use <php include 'vars.php'; >
copy paste google.
<?php echo "<table>"; ($x = 1; $x <= 10; $x++) { ${'game' . $x} = $x; $game1 = "gta5"; $game2 = "dirt3"; $game3 = "skyrim"; echo "<th>".$game."</th>"; } echo "</table>"; ?>
i want make loop, variable changes on each loop , outputs preset name or text. hoping happen here is, after each loop $x
output "game1" "game2" "game3" etc, , because i've preset variables.
$game1 = "gta5"; $game2 = "dirt3"; $game3 = "skyrim";
i thought <th>
inner change "gta5"
"dirt3"
"skyrim"
.
why need this? have created table , part want loop.
<th><div class='text'>gta5</div><div class='grid'><div onclick='()' class="res">1080p ></div><div onclick='()' class="res">1440p ></div><div onclick='()' class="res">4k ></div></div></th> <th><div class="text"><p>gta5</p><span>1080p</span></div><div onclick='()' class="btn">></div></th> <th><div class="text"><p>gta5</p><span>min fps</span></div></th> <th><div class="text"><p>gta5</p><span>max fps</span></div></th> <th><div class="text"><p>gta5</p><span>used vram</span></div></th> <th><div class="text"><p>gta5</p><span>1440p</span></div><div onclick='()' class="btn">></div></th> <th><div class="text"><p>gta5</p><span>min fps</span></div></th> <th><div class="text"><p>gta5</p><span>max fps</span></div></th> <th><div class="text"><p>gta5</p><span>used vram</span></div></th> <th><div class="text"><p>gta5</p><span>4k</span></div><div onclick='()' class="btn">></div></th> <th><div class="text"><p>gta5</p><span>min fps</span></div></th> <th><div class="text"><p>gta5</p><span>max fps</span></div></th> <th><div class="text"><p>gta5</p><span>used vram</span></div></th>
i need loop 13 times , on each loop, name "gta5"
needs change. first tiny code "try" bigger thing.
instead of having $game1, $game2, $game3 etc, turn variable $game array list of games inside.
<?php $game = array("game1","game2","game3","etc"); $screen = array("4k","1080p","720p","480p"); echo '<table>'; $i=0; while($i <4){ echo '<th><div class="text"><p>'.$game[$i].'</p><span>'.$screen[$i].'</span></div><div onclick="()" class="btn"></div></th>'; echo '<th><div class="text"><p>'.$game[$i].'</p><span>min fps</span></div></th>'; echo '<th><div class="text"><p>'.$game[$i].'</p><span>max fps</span></div></th>'; $i++; } echo '<table>';
Comments
Post a Comment