I would really appreciate your help.
I want to use an additional array with foreach.
Currently it looks like this and works perfectly.
<?php
$listcity = array("Negril" => "negril",
"Kingston" => "kingston",
"Ocho Rios" => "ocho-rios");
foreach ($listcity as $cityname => $citylink) {
echo "<li data-name=\"$cityname Hotels\"><a href=\"https://example.com/hotels/$citylink\">$cityname</a></li>";
}
?>
Now I want to add a span with the following numbers:
$distancemiles = array("Negril" => "25",
"Kingston" => "10",
"Ocho Rios" => "67");
I want the final echo to be the following:
<li data-name=\"$cityname Hotels\"><a href=\"https://example/hotels/$citylink\">$cityname</a><span>(HERE THE DISTANCE IN MILES miles)</span></li>
so that the browser outputs for instance:
So I would like to know how I can combine my three sources of data:
$cityname --> Should be the name of the city
$citylink --> Should be the link ending
$distancetocity --> Should be the distance
Would someone help me with this? I've tried very hard to make it work and read through all kinds of online tutorials, but I fail every time.
Best,
Max