如何从php中序列化数据获取“file_url”?

时间:2015-07-16 04:43:17

标签: php wordpress serialization

我希望从中获取数据file_url

a:1:{s:5:"bIrq7";a:6:{s:14:"user_file_name";s:15:"Recruitment.pdf";s:9:"file_name";s:15:"recruitment.pdf";s:9:"file_path";s:76:"/home3/fashion/public_html/thesafetyjobs.com/wp-content/uploads/ninja-forms/";s:8:"file_url";s:71:"http://thesafetyjobs.com/wp-content/uploads/ninja-forms/recruitment.pdf";s:8:"complete";s:1:"1";s:9:"upload_id";s:2:"28";}}`

我该怎么做?

1 个答案:

答案 0 :(得分:2)

尝试maybe_unserialize()函数返回一个数组 您可以尝试此代码

$data = 'a:1:{s:5:"bIrq7";a:6:{s:14:"user_file_name";s:15:"Recruitment.pdf";s:9:"file_name";s:15:"recruitment.pdf";s:9:"file_path";s:76:"/home3/fashion/public_html/thesafetyjobs.com/wp-content/uploads/ninja-forms/";s:8:"file_url";s:71:"http://thesafetyjobs.com/wp-content/uploads/ninja-forms/recruitment.pdf";s:8:"complete";s:1:"1";s:9:"upload_id";s:2:"28";}}';
$un_serialize = maybe_unserialize($data);
echo $un_serialize['bIrq7']['file_url'];