E
E
Evgeny Kylin2016-05-23 18:21:47
PHP
Evgeny Kylin, 2016-05-23 18:21:47

How to parse a non-associative JSON array in PHP?

$data = '["soderjymoe"]';
$data_j = json_decode($data, true);
echo $data_j[0];

json_last_error writes a syntax error.
Tried with JSON_FORCE_OBJECT, doesn't help either.

Answer the question

In order to leave comments, you need to log in

3 answer(s)
C
Cat Anton, 2016-05-23
@27cm

https://ideone.com/fu7mlN

A
Andrey, 2016-05-23
@VladimirAndreev

json_last_error writes a syntax error.
well that means the json is invalid...

T
titronfan, 2016-05-23
@titronfan

$data = '["soderjymoe"]';
$data_j = json_decode($data);
echo $data_j[0];

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question