我有一个看起来像数组的字符串:-
'[["hello","world"],["etc","etc..."]]'
有没有一种方法可以"取消序列化"它,即使它不是真正合适的序列化格式。
您可以将其作为数组返回,因为它是JSON:
$json = '[["hello","world"],["etc","etc..."]]';
$decoded = json_decode($json, true); // true option returns associative array
print_r($decoded);
退货:
Array
(
[0] => Array
(
[0] => hello
[1] => world
)
[1] => Array
(
[0] => etc
[1] => etc...
)
)
您可以在此字符串上使用json_decode
函数。