I have an array like this :
Array
(
[0] => Array
(
[objectid] => 197
[adresse] => D554
[city] => NEW-YORK
[lat] => 12,545484654687
[long] => 12,545484654687
)
[1] => Array
(
[objectid] => 198
[adresse] => D556
[city] => WASHINGTON
[lat] => 12,545484654687
[long] => 12,545484654687
)
...
...
)
I want to change the city name by an identifier like 0, 1, 2...
Actually, I done this by this code :
foreach ($big_array as $key => $value){
if ($value['city'] == "NEW-YORK"){
$big_array[$key] = str_replace("NEW-YORK", 0, $value);
} elseif($value['city'] == "WASHINGTON") {
$big_array[$key] = str_replace("WASHINGTON", 1, $value);
} etc...
}
I don't think it's the best way to do that, I have a huge list of cities. Is it possible to define an array like :
$replacements = array(
"NEW-YORK" => 0,
"WASHINGTON" => 1,
etc...
)
and use a function to perform the change simply ?