0

I need to get the values of a custom field list type with sql. I extract the fieldparams value using

SELECT  fieldparams,id  FROM #__fields where context='com_content.article' and state=1

And i get a string like this

{"multiple":"0","options":{
"options0":{"name":"name1","value":"value1"},
"options1":{"name":"name2","value":"value2"}}}

How do I convert this string into an array?

1
  • This question belongs to stackoverflow, because you are asking about converting JSON strings to PHP arrays, which is not primarily a Joomla question. Mar 1 '18 at 11:01
5
$your_array = json_decode($json_data, true);

More about the decode options: http://php.net/manual/de/function.json-decode.php

More about JSON: http://php.net/manual/en/ref.json.php

4
  • 1
    This is backwards, Dennis. Mar 1 '18 at 22:14
  • 1
    You can’t echo an array, Dennis. Mar 2 '18 at 11:45
  • 1
    Thank you for giving a helping hand by pointing out things via comments, instead of just editing that obvious mistake, James. Mar 2 '18 at 11:54
  • 2
    My pleasure. ;) Mar 2 '18 at 23:54

Not the answer you're looking for? Browse other questions tagged or ask your own question.