反序列化非标准字符串
Unserialize non standard string
我有一个看起来像数组的字符串:-
'[["hello","world"],["etc","etc..."]]'
有没有办法 'unserialize' 这虽然不是真正正确的序列化格式。
您可以在此字符串上使用 json_decode
函数。
你可以 return 它作为一个数组 JSON:
$json = '[["hello","world"],["etc","etc..."]]';
$decoded = json_decode($json, true); // true option returns associative array
print_r($decoded);
returns:
Array
(
[0] => Array
(
[0] => hello
[1] => world
)
[1] => Array
(
[0] => etc
[1] => etc...
)
)
我有一个看起来像数组的字符串:-
'[["hello","world"],["etc","etc..."]]'
有没有办法 'unserialize' 这虽然不是真正正确的序列化格式。
您可以在此字符串上使用 json_decode
函数。
你可以 return 它作为一个数组 JSON:
$json = '[["hello","world"],["etc","etc..."]]';
$decoded = json_decode($json, true); // true option returns associative array
print_r($decoded);
returns:
Array
(
[0] => Array
(
[0] => hello
[1] => world
)
[1] => Array
(
[0] => etc
[1] => etc...
)
)