I have string value like below
$param = "{{1,0},{1}}";
I want to convert above string value to array as similar to below using php
Array
(
[0] => Array
(
[0] => 1
[1] => 0
)
[1] => Array
(
[0] => 1
)
)
Any help would be appreciated.
This should solve your problem
$param = "{{1,0},{1}}";
$string = str_replace(['{','}'], ['[',']'], $param);
print_r(json_decode($string,true));
I replaced all curly braces with square brackets in array and made it in json format to decode it.
Here is your working demo .
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.