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?

2 Answers 2

3

json_decode() in PHP will be your friend, see the docs: http://docs.php.net/manual/de/function.json-decode.php

Something like this:

$json = '{"a":1,"b":2,"c":3,"d":4,"e":5}'; var_dump(json_decode($json)); var_dump(json_decode($json, true)); 
Sign up to request clarification or add additional context in comments.

Comments

0

You need to json decode the result

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

To simply display the result once decoded, you can use

echo $image; 

or maybe if you wanted to display the actual image, you could use this:

<img src="<?php echo JUri::root() . $image; ?>" /> 

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.