Php 取消序列化非标准字符串
我有一个看起来像数组的字符串:-Php 取消序列化非标准字符串,php,deserialization,Php,Deserialization,我有一个看起来像数组的字符串:- '[["hello","world"],["etc","etc..."]]' 是否有一种方法可以“取消序列化”,即使它不是真正正确的序列化格式。您可以在此字符串上使用函数。您可以在此字符串上使用函数。您可以将其作为数组返回,因为它是JSON: $json = '[["hello","world"],["etc","etc..."]]'; $decoded = json_decode($json, true); // true option returns as
'[["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:
$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序列化对象,我的意思是它不是php serialize()序列化的数组。php的unserialize()函数对其不起作用。序列化数据的哪些方面不正确/不正确。您发布的是一个JSON序列化对象,我的意思是它不是php serialize()序列化的数组。php的unserialize()函数对其不起作用。