CyberShot Posted March 30, 2018 Share Posted March 30, 2018 I have this array and I am trying to get the image value print_r($image); Array ( [0] => Array ( [image] => 32 [image_fallback] => ) [1] => Array ( [image] => 31 [image_fallback] => ) ) The only way I have been able to get it to work is by doing this foreach($image as $key){ foreach($key as $value){ $imageID = wp_get_attachment_image($value,'full'); // gets the attachment image from the image ID.. 31, 32 from the above array echo $imageID; // prints out the image tag with the url to the image } } The above code does give me the desired result. What I want to know is if there is a sexier way to getting it done? Is this considered propper? Quote Link to comment Share on other sites More sharing options...
Solution kicken Posted March 30, 2018 Solution Share Posted March 30, 2018 I'd guess something like this would work for you. foreach ($image as $img){ $imageID = wp_get_attachment_image($img['image'], 'full'); echo $imageID; } In your original code you would run wp_get_attachment_image twice, once for the [image] key and once for the [image_fallback] key which is probably not what you intended to do. If you only want the [image] key then just access it directly. 1 Quote Link to comment Share on other sites More sharing options...
Psycho Posted March 30, 2018 Share Posted March 30, 2018 What I want to know is if there is a sexier way to getting it done? Using kicken's code as a starting point, this is the 'sexiest' way I can come up with foreach ($image as $img){ $imageID = wp_get_attachment_image($img['image'], 'full'); // Sexy?Sex // ?Sexy?Sexy // y?Sexy?Sexy? // ?Sexy?Sexy?S // ?Sexy?Sexy?S // ?Sexy?Sexy?Se // ?Sexy?Sexy?Se // ?Sexy?Sexy?Se // ?Sexy?Sexy?Sexy? // ?Sexy?Sexy?Sexy?Sexy // ?Sexy?Sexy?Sexy?Sexy?Se // ?Sexy?Sexy?Sexy?Sexy?Sex // ?Sexy? ?Sexy?Sexy?Sex // ?Sex ?Sexy?Sexy? // ?Sex ?Sexy?Sexy // ?Sex ?Sexy?Sexy // ?Sex ?Sexy?Sexy // ?Se ?Sexy?Sex // ?Se ?Sexy?Sexy // ?Sexy?Sexy?Sex // ?Sexy?Sexy?sex // ?Sexy?Sexy?Sexy?Se // ?Sexy?Sexy?Sexy?Sexy? // ?Sexy?Sexy?Sexy?Sexy?Sexy // ?Sexy?Sexy?Sexy?Sexy?Sexy?S // ?Sexy?Sexy ?Sexy?Sexy?se // ?Sexy?Se ?Sexy?Sexy? // ?Sexy?Se ?Sexy?Sexy? // ?Sexy?S ?Sexy?Sexy // ?Sexy?S ?Sexy?Sexy // ?Sexy?Sexy?Sexy // ?Sexy?Sexy?S // ?Sexy?Sexy // ?Sexy?Se // ?Sexy? // ?Sexy? // ?Sexy? // ?Sexy? // ?Sexy // ?Sexy // ?Sex // ?Sex // ?Sex // ?Sexy // ?Sexy // Sexy // Sexy? // SexY echo $imageID; } 2 Quote Link to comment Share on other sites More sharing options...
CyberShot Posted March 31, 2018 Author Share Posted March 31, 2018 Using kicken's code as a starting point, this is the 'sexiest' way I can come up with foreach ($image as $img){ $imageID = wp_get_attachment_image($img['image'], 'full'); // Sexy?Sex // ?Sexy?Sexy // y?Sexy?Sexy? // ?Sexy?Sexy?S // ?Sexy?Sexy?S // ?Sexy?Sexy?Se // ?Sexy?Sexy?Se // ?Sexy?Sexy?Se // ?Sexy?Sexy?Sexy? // ?Sexy?Sexy?Sexy?Sexy // ?Sexy?Sexy?Sexy?Sexy?Se // ?Sexy?Sexy?Sexy?Sexy?Sex // ?Sexy? ?Sexy?Sexy?Sex // ?Sex ?Sexy?Sexy? // ?Sex ?Sexy?Sexy // ?Sex ?Sexy?Sexy // ?Sex ?Sexy?Sexy // ?Se ?Sexy?Sex // ?Se ?Sexy?Sexy // ?Sexy?Sexy?Sex // ?Sexy?Sexy?sex // ?Sexy?Sexy?Sexy?Se // ?Sexy?Sexy?Sexy?Sexy? // ?Sexy?Sexy?Sexy?Sexy?Sexy // ?Sexy?Sexy?Sexy?Sexy?Sexy?S // ?Sexy?Sexy ?Sexy?Sexy?se // ?Sexy?Se ?Sexy?Sexy? // ?Sexy?Se ?Sexy?Sexy? // ?Sexy?S ?Sexy?Sexy // ?Sexy?S ?Sexy?Sexy // ?Sexy?Sexy?Sexy // ?Sexy?Sexy?S // ?Sexy?Sexy // ?Sexy?Se // ?Sexy? // ?Sexy? // ?Sexy? // ?Sexy? // ?Sexy // ?Sexy // ?Sex // ?Sex // ?Sex // ?Sexy // ?Sexy // Sexy // Sexy? // SexY echo $imageID; } LOL Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.