Jump to content

How do i loop through this array?


Perad

Recommended Posts

I have an array which contains the names on an input form and image names.

[code]$maps["Beltot"] = "beltot.jpg";
$maps["Brecourt"] = "brecourt.jpg";
$maps["Burgundy"] = "burgundy.jpg";
$maps["Caen"] = "caen.jpg";
$maps["Carentan"] = "carentan.jpg";
$maps["El Alamein"] = "elala.jpg";
$maps["Leningrad"] = "leningrad.jpg";
$maps["Matmata"] = "matmata.jpg";
$maps["Moscow"] = "moscow.jpg";
$maps["Rostov"] = "rostov.jpg";
$maps["St.Mere Eglise"] = "stmere.jpg";
$maps["Stalingrad"] = "stalingrad.jpg";
$maps["Toujane"] = "toujane.jpg";
$maps["Villers-Bocage"] = "villers.jpg";
$maps["Wallendar"] = "wallendar.jpg";[/code]

I have called the values from the database.

[code]$map1 = $row['map1'];
$map2 = $row['map2'];[/code]

How do i compare $map1 with the $maps array to find the right image?
Link to comment
https://forums.phpfreaks.com/topic/32168-how-do-i-loop-through-this-array/
Share on other sites

try ucword() so you get all the letters in the word lower case, then add ".jpg" to the end of each word, however, I do find some exceptions such as
$maps["El Alamein"] = "elala.jpg";
$maps["Villers-Bocage"] = "villers.jpg";
may be you should change these to fit the rest.

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.