how does a string convert into an array?

You can use json_decode() :

$string = "1,[1,2,3],[2,2,4],2,3";
$array = json_decode("[$string]", true);
print_r($array);

Output :

Array
(
    [0] => 1
    [1] => Array
        (
            [0] => 1
            [1] => 2
            [2] => 3
        )

    [2] => Array
        (
            [0] => 2
            [1] => 2
            [2] => 4
        )

    [3] => 2
    [4] => 3
)

Above code tested here

CLICK HERE to find out more related problems solutions.

Leave a Comment

Your email address will not be published.

Scroll to Top