Before writing this I did some research.
This is my first-ever code I did in PHP.
I did use <php include 'vars.php'; > but that was just a copy paste from google.
<?php
echo "<table>";
for ($x = 1; $x <= 10; $x++) {
${'game' . $x} = $x;
$game1 = "GTA5";
$game2 = "Dirt3";
$game3 = "Skyrim";
echo "<th>".$game."</th>";
}
echo "</table>";
?>
I want to make a loop, where the variable changes on each loop and outputs a preset name or text. What I was hoping will happen here is, that after each loop the $x will output "game1" "game2" "game3" etc, and because I've already preset the variables.
$game1 = "GTA5";
$game2 = "Dirt3";
$game3 = "Skyrim";
I thought that the <th> inner will change to "GTA5" "Dirt3" "Skyrim".
Why do I need this? I have created a Table and this is a part that I want to 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 to loop this 13 times and on each loop, the name "GTA5" needs to change.
The first tiny code was just a "try" for the bigger thing.
$games = array("GTA5", "Dirt3, "Skyrim"); ... echo $games[$x-1];or the like. Much simpler, much more flexible. Official documentation here.