I want to display an image from an XML request for each unique ID. A total of three images should be displayed, but I’m getting the same image three times.
The IDs are storing correctly here:
$simIds = array(
"id1" => $similarObject->place[0]['place_id'],
"id2" => $similarObject->place[1]['place_id'],
"id3" => $similarObject->place[2]['place_id'],
);
Here’s my foreach loop:
foreach ($simIds as $foo) {
$simPhotoFile = $photoUrl.$foo;
$simPhotoObject = simplexml_load_file($simPhotoFile);
$simPhotoSrc = array (
'src1' => $simPhotoObject->photos->photo_set->square,
'src2' => $simPhotoObject->photos->photo_set->square,
'src3' => $simPhotoObject->photos->photo_set->square,
);
}
The relevant HTML:
<p><img src="<?= $simPhotoSrc['src1'] ?>" alt="Image load failed" /><img src="<?= $simPhotoSrc['src2'] ?>" alt="Image load failed" /><img src="<?= $simPhotoSrc['src3'] ?>" alt="Image load failed" /></p>
Im not really sure what I’m doing wrong at this point, or if there is maybe a better way to go about this. Thanks for any help!
html: