0

I have to parse values from a json string like this:

[{"type":"list","value":["A","B"],"field":"scheda"}] 

How can I do that using PHP function json_decode?

For example I want print:

field = "scheda"
values = "A,B"
i alarmed alien
9,5403 gold badges30 silver badges40 bronze badges
asked Oct 4, 2013 at 16:13

2 Answers 2

4
$json = json_decode('[{"type":"list","value":["A","B"],"field":"scheda"}]');
print 'field = "'.$json[0]->field.'"'."\n";
print 'values = "'.implode(",",$json[0]->value).'"'."\n";
MrCode
64.6k10 gold badges95 silver badges114 bronze badges
answered Oct 4, 2013 at 16:17
Sign up to request clarification or add additional context in comments.

Comments

0

If you can't use json_decode(), why not try a class?

For instance, something like... http://www.phpclasses.org/package/4205-PHP-Serialize-and-unserialize-values-in-JSON-format.html

answered Oct 4, 2013 at 16:17

Comments

Your Answer

Draft saved
Draft discarded

Sign up or log in

Sign up using Google
Sign up using Email and Password

Post as a guest

Required, but never shown

Post as a guest

Required, but never shown

By clicking "Post Your Answer", you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.