Answer the question
In order to leave comments, you need to log in
Can't parse json. Can you help?
It is necessary to parse json through foreach.
Did it like this:
$arr = json_decode('[
{
"name": "test1",
},
{
"name": "test2",
}
]', true);
foreach($arr as $item) {
echo $item['name'];
}
Answer the question
In order to leave comments, you need to log in
Wrong format. Extra commas. There must be no commas before the closing brace.
Well, firstly, your JSON is incorrectly described. It must be so...
$arr = json_decode(' {"my_array": [
{
"name": "test1"
},
{
"name": "test2"
}
]}', true);
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question