ATTENTION: You are viewing a page formatted for mobile devices; to view the full web page, click HERE.

Other Software > Developer's Corner

[PHP] 'Dynamic variable name' ?

<< < (2/2)

f0dder:
Instead of your idea of "$map$i", you'd use multi-dimension arrays, or an array of arrays... like
--- Code: PHP ---$ubermap[i] = str_split($line);

RedPillow:
Thanks!
It's working now as so:
(Btw, any 'better' way to thank like reputation + etc. ?)

--- Code: PHP ---$i = 0;        $openMap = fopen("map/map_1-1.txt", "r");                while (!feof($openMap)) {                        $line = fgets($openMap);                        $map[$i] = str_split($line);                        $i++;                }fclose($openMap); for ($row = 0; $row <= 13; $row++){    for ($col = 0; $col <= 13; $col++)    {                if ($map[$row][$col] == 'X') {                        echo "<img src = 'img/wall/X.jpg'/>";}                elseif ($map[$row][$col] == 'G') {                        echo "<img src = 'img/terrain/G.jpg'/>";}    }}

jgpaiva:
(Btw, any 'better' way to thank like reputation + etc. ?)
-RedPillow (February 05, 2011, 05:00 PM)
--- End quote ---
No reputation system, Eternal Gratefulness will also work nicely. But if there was a reputation system in place, f0dder would obviously be off the scale anyways :P

Ath:
No reputation system, Eternal Gratefulness will also work nicely.
-jgpaiva (February 18, 2011, 08:50 AM)
--- End quote ---
Or a (small) donation to the person that helped you out so nicely :-[

jgpaiva:
Ath: obviously, I'm embarrassed I didn't think of that first!  :-[

Navigation

[0] Message Index

[*] Previous page

Go to full version