I am trying to display the intro image from Joomla 3.2, this is saved into the database in the 'images' column within the table. However, the intro image and the full text image is saved into the same column, so when I'm trying to echo that column I'm just getting the values.

I'm seeing the values by this:

<?php echo $item->images; ?>

This is outputting the following:

{"image_intro":"images/stories/imagetest.jpg","float_intro":"","image_intro_alt":"","image_intro_caption":"","image_fulltext":"","float_fulltext":"","image_fulltext_alt":"","image_fulltext_caption":""}

Ideally though, I want to be able to strip the html out and only display the value for the "image_intro" which I can then use for the img src. The above appears to be in JSON format but I can't figure out how to just echo the first value.

有帮助吗?

解决方案

Try this:

$decodedJsonString = json_decode('{"image_intro":"images/stories/Catcchampcocktails (2).jpg","float_intro":"","image_intro_alt":"","image_intro_caption":"","image_fulltext":"","float_fulltext":"","image_fulltext_alt":"","image_fulltext_caption":""}');

echo $decodedJsonString->image_intro;
许可以下: CC-BY-SA归因
不隶属于 StackOverflow
scroll top