Jump to content

[SOLVED] PHP array key is a letter


richrock

Recommended Posts

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  :confused:

 

            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

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.