Variable representation

From: Date: Mon, 02 Apr 2012 03:52:31 +0000
Subject: Variable representation
Groups: php.general 
Request: Send a blank email to php-general+get-317410@lists.php.net to get a copy of this message
Hi Everyone: I am assigning the value of 4 images to variables following a database query: $image_1 = stripslashes( $row['image_1'] ); $image_2 = stripslashes( $row['image_2'] ); $image_3 = stripslashes( $row['image_3'] ); $image_4 = stripslashes( $row['image_4'] ); What I need help with is how to represent the variable using $i for the number portion in the following WHILE loop. I am not sure of how to correctly do it. I am referring to: $image_{$i} === $i = 1; while ( $i <= 4 ) { if ( trim( $image_{$i} ) <> "" ) { echo "<li><a href=\"http://www.theverseoftheday.info/store-images/" . $image_{$i} . "\" title=\"Image " . $i . "\">Image " . $i . "</a></li>\r\n"; } ++$i; } === How do I substitute $i for the # so I may use a WHILE loop to display the images? (Not all 4 variables have an image.) Ron Piggott www.TheVerseOfTheDay.info

« previous php.general (#317410) next »