mainstreetop Posted March 7, 2011 Share Posted March 7, 2011 I have an array ($other_images) that contains image file names separated by semi colons. I can successfully echo the individual values using echo $other_images[0], $other_images[1], $other_images[2]... When I put it in a for loop, though, I run into the followng error: Parse error: syntax error, unexpected T_CONSTANT_ENCAPSED_STRING, expecting ',' or ';' in... Here is my code: <?php $other_images = explode(";", $data['ItemAltImage']); for($i=0; $i<count($other_images); $i++) { echo "<p><img src='http:\\www.oppictures.com\SINGLEIMAGES\100\" . $other_images[$i] . "' /></p>"; } ?> This is the result of print_r($other_images): Array ( [0] => UNV21200_3_2.JPG [1] => UNV21200_2_2.JPG [2] => UNV21200_4_1.JPG [3] => UNV21200_8_1.JPG [4] => UNV21200_5_1.JPG [5] => UNV21200_6_1.JPG [6] => UNV21200_7_1.JPG [7] => UNV21200_9_1.JPG ) Do you see where I'm making a mistake? Thanks Link to comment https://forums.phpfreaks.com/topic/229839-parse-error-rendering-array/ Share on other sites More sharing options...
mainstreetop Posted March 7, 2011 Author Share Posted March 7, 2011 As an edit to my original post, I noticed (when viewing the html page source) the following: <p><img src='http:\www.oppictures.com\SINGLEIMAGES@$x[0]' </p> I'm not sure why the @ symbol is being rendered. Any ideas? Link to comment https://forums.phpfreaks.com/topic/229839-parse-error-rendering-array/#findComment-1183853 Share on other sites More sharing options...
mainstreetop Posted March 7, 2011 Author Share Posted March 7, 2011 I'm an idiot... switched the backslashes in the path to forward slashes. Problem solved! Link to comment https://forums.phpfreaks.com/topic/229839-parse-error-rendering-array/#findComment-1183861 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.