我需要小key
和url
作为值,例如: -
small-> upload \ 2016 \ 04 \ greenfield-100x100.jpg
"a:3:{s:5:\"small\";s:39:\"\/uploads\/2016\/04\/greenfield-100x100.jpg\";s:6:\"medium\";s:39:\"\/uploads\/2016\/04\/greenfield-300x200.jpg\";s:5:\"large\";s:39:\"\/uploads\/2016\/04\/greenfield-500x400.jpg\";}""
答案 0 :(得分:1)
您需要使用unserialize
将数据设为可读/可理解。您的数据有效。
unserialize()
接受一个序列化变量并将其转换回来 到PHP值。
$data = "a:3:{s:5:\"small\";s:39:\"/uploads/2016/04/greenfield-100x100.jpg\";s:6:\"medium\";s:39:\"/uploads/2016/04/greenfield-300x200.jpg\";s:5:\"large\";s:39:\"/uploads/2016/04/greenfield-500x400.jpg\";}";
$out = unserialize($data);
print_r($out);
unserialize
之后的结果。
Array
(
[small] => /uploads/2016/04/greenfield-100x100.jpg
[medium] => /uploads/2016/04/greenfield-300x200.jpg
[large] => /uploads/2016/04/greenfield-500x400.jpg
)