richrock Posted August 28, 2009 Share Posted August 28, 2009 Hey all - I've created an array of image names to display in a gallery, and want to use a number to store in a subfolder. So I though I'd be clever and use the array's key - but returning the key shows a letter, not a number. What am I doing wrong foreach($web_images as $key => $webimage ) { if (($webimage == '-1') || ($webimage == NULL)) { echo ""; } else { $img_size_array = getimagesize("gallery/web/".$webimage); $img_width =$img_size_array[0]; echo "<img src='gallery/web/"; echo $webimage; echo "' class='gallery-detail-image'"; if($img_width < 600) { echo "style='margin-right:24px;'"; } echo "title='"; echo $web_images_alt[$key]; echo "'"; echo "/>"; echo "KeyVal = " . $webimage[$key]."<br />"; I added the KeyVal bit to see what the array key was. I currently have it displaying 'a' and 'b' Link to comment https://forums.phpfreaks.com/topic/172269-solved-php-array-key-is-a-letter/ Share on other sites More sharing options...
richrock Posted August 28, 2009 Author Share Posted August 28, 2009 Ignore - I solved it. Was referencing the wrong part for getting the array key. Link to comment https://forums.phpfreaks.com/topic/172269-solved-php-array-key-is-a-letter/#findComment-908282 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.