1

I want to take some information created in a Joomla article into a separate system separate from Joomla. Here is an example value returned from a field I grabbed from a MySQL query (the column is "images" from the "com_content" table):

{"image_intro":"images\/Capitol_-_D_C__-_Daytime.jpg","float_intro":"right","image_intro_alt":"","image_intro_caption":"","image_fulltext":"","float_fulltext":"","image_fulltext_alt":"","image_fulltext_caption":""}

Now in PHP I want to convert this sucker into an array. Any ideas?

4

2 回答 2

3

json_decode()在 PHP 中将成为您的朋友,请参阅文档: http ://docs.php.net/manual/de/function.json-decode.php

像这样的东西:

$json = '{"a":1,"b":2,"c":3,"d":4,"e":5}';
var_dump(json_decode($json));
var_dump(json_decode($json, true));
于 2014-06-10T22:16:26.740 回答
0

您需要对结果进行 json 解码

$image_intro = json_decode($image);
$image = $image_intro->image_intro;

要简单地显示解码后的结果,您可以使用

echo $image;

或者如果你想显示实际图像,你可以使用这个:

<img src="<?php echo JUri::root() . $image; ?>" />
于 2014-06-10T22:18:12.040 回答