Please tell me how you can break this line:

[[1000,1500,5000,10000,19000,6000],[5,20,30,40,50,60]] 

in two arrays? I read that it is possible with the help of a regular expression, but with me it’s not very regular.

  • 3
    rather json_decode)) - sepgg
  • @sepgg yes of course: D was sealed up - Naumov
  • If you are given an exhaustive answer, mark it as correct (a daw opposite the selected answer). - Nicolas Chabanovsky

2 answers 2

This is a typical JSON string. Apply the json_decode() function to it.

 $str = '[[1000,1500,5000,10000,19000,6000],[5,20,30,40,50,60]]'; $arr = json_decode($str, false, 3); if (!$arr) die(json_last_error_msg()); var_dump($arr); 

    Regulars are not needed here. Just convert the JSON string to an array:

     $json_string = '[[1000,1500,5000,10000,19000,6000], [5,20,30,40,50,60]]'; $arr = json_decode($json_string);