Search code examples
phpmysqljoomlajoomla3.3

Converting Joomla value from database into PHP array


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?


Solution

  • 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));