-6

how can I parse this string into an array using php?.

[[1406906881,9.3],[1406907001,9.5],[1406907061,9.5],[1406907121,9.8],[1406907181,9.4],[1406907241,9.6],[1406907361,9.3],[1406907421,9.3],[1406907481,9.1],[1406907541,9.2],[1406907601,9],[1406907661,9],[1406907781,8.9],[1406907841,9],]
user2820116
  • 101
  • 1
  • 6

2 Answers2

0

Looks like you have a trailing comma

[1406907661,9],[1406907781,8.9],[1406907841,9],]
                                              ^

Not sure if that's what you're asking about.

Lfa
  • 1,069
  • 2
  • 10
  • 23
0

You can parse this using json_decode() function in PHP. That string looks like json array.

Also, fix that trailing comma in the string (as mentioned by Alf).

Working example:

<pre>
<?php

$jsonArr = json_decode('[[1406906881,9.3],[1406907001,9.5],[1406907061,9.5],[1406907121,9.8],[1406907181,9.4],[1406907241,9.6],[1406907361,9.3],[1406907421,9.3],[1406907481,9.1],[1406907541,9.2],[1406907601,9],[1406907661,9],[1406907781,8.9],[1406907841,9]]');

print_r($jsonArr);

?>

Outputs:

enter image description here

Latheesan
  • 23,247
  • 32
  • 107
  • 201