a:6:{s:4:"name";s:15:"eMPB_Banner.jpg";s:10:"uploadName";s:30:"homeHeaderTitleImage_en_US.jpg";s:5:"width";i:779;s:6:"height";i:84;s:12:"dateUploaded";s:19:"2010-07-26 19:18:13";s:7:"altText";s:0:"";}
我想提取这段中的homeHeaderTitleImage_en_US.jpg这句,应该怎么写啊,高手指教一下

解决方案 »

  1.   

    根据uploadName来标记吧
    /uploadName";s:\d+:"(.*?)"/
      

  2.   

    $str='a:6:{s:4:"name";s:15:"eMPB_Banner.jpg";s:10:"uploadName";s:30:"homeHeaderTitleImage_en_US.jpg";s:5:"width";i:779;s:6:"height";i:84;s:12:"dateUploaded";s:19:"2010-07-26 19:18:13";s:7:"altText";s:0:"";}';
    $r=unserialize ($str);;
    var_dump($r['uploadName']);
      

  3.   

    想要将已序列化的字符串变回 PHP 的值,可使用 unserialize()
    不过非要用正则的话,preg_match("/s:\d+:"uploadName";s:\d+:"(.*)";/", $str, $match); $match[1]就是你要的了