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?

closed as off-topic by Dennis Heiden, TryHarder, Mikan, Neil Robertson, NivF007 Mar 3 '18 at 0:12

This question appears to be off-topic. The users who voted to close gave this specific reason:

  • "Questions must be specific to Joomla. Generic questions about web, programming, 3rd party software, servers, hosting etc, even if they are found in the Joomla-sphere, are off-topic. It might be better asked at Stack Overflow or another SE Site. For Joomla Extension Support better use their developers' support channels first. More info: help center" – TryHarder, Mikan, Neil Robertson, NivF007
If this question can be reworded to fit the rules in the help center, please edit the question.

  • This question belongs to stackoverflow, because you are asking about converting JSON strings to PHP arrays, which is not primarily a Joomla question. – Dennis Heiden 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

  • 1
    This is backwards, Dennis. – jamesgarrett Mar 1 '18 at 22:14
  • 1
    You can’t echo an array, Dennis. – jamesgarrett 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. – Dennis Heiden Mar 2 '18 at 11:54
  • 2
    My pleasure. ;) – jamesgarrett Mar 2 '18 at 23:54

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