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' ?

(1/2) > >>

RedPillow:
This is something I've managed to do so far:

--- Code: PHP ---function generateMap {        $i = 0;                $openMap = fopen("map/map_1-1.txt", "r");                        while (!feof($openMap)) {                                $line = fgets($openMap, 1024);                                        $map = str_split($line);
The problem is, that I want to name the array $map like $map$i  or $map + $i...
So that it's like $map1 = blah, $map2 = blah, $map3 = blah ...

Do you get me?
How do I do that?

f0dder:
Why not use arrays instead?

RedPillow:
Whaat?

I want to get every line of the text-file.
Then spilt those lines to arrays called map1, map2, map3 ... where each character of the line is one cell of an array.
But how do I name the $map differently after every loop?

like $map$i or somrthing?

Ath:
Do as the man says, use an array.

RedPillow:
What do you mean?
Aren't I using arrays when splitting the lines to an array?

Navigation

[0] Message Index

[#] Next page

Go to full version