1

我正在尝试显示来自 Joomla 3.2 的介绍图像,它保存在表中“图像”列中的数据库中。但是,介绍图像和全文图像保存在同一列中,因此当我尝试回显该列时,我只是获取值。

我看到了这个值:

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

这将输出以下内容:

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

理想情况下,我希望能够剥离 html 并只显示“image_intro”的值,然后我可以将其用于 img src。以上似乎是 JSON 格式,但我不知道如何回显第一个值。

4

1 回答 1

1

尝试这个:

$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;
于 2014-01-30T14:14:29.270 回答