drzrdc1766788 2015-02-24 13:55
浏览 43

从字段中提取值的有效方法

One of my plugin is storing data in form of

a:2:{i:0;s:20:\"HELM Operational (O)\";i:1;s:19:\"HELM Management (M)\";}

In database . I want to get the values such as "HELM Operational,HELM Management" in php . How can i extract the values and get it into a variable in the desired form . I know we can use Explode to explode after " but there is dynamic non wanted values in between such as i:1,s:19 etc which will be different every time . Is this possible using php to get the desired outcome ?

  • 写回答

1条回答 默认 最新

  • dougaxing8673 2015-02-24 14:23
    关注

    If you can't fix the malformed data at source:

    $data = 'a:2:{i:0;s:20:\"HELM Operational (O)\";i:1;s:19:\"HELM Management (M)\";}';
    $data = unserialize(str_replace('\"', '"', $data));
    var_dump($data);
    
    评论

报告相同问题?

悬赏问题

  • ¥100 set_link_state
  • ¥15 虚幻5 UE美术毛发渲染
  • ¥15 CVRP 图论 物流运输优化
  • ¥15 Tableau online 嵌入ppt失败
  • ¥100 支付宝网页转账系统不识别账号
  • ¥15 基于单片机的靶位控制系统
  • ¥15 真我手机蓝牙传输进度消息被关闭了,怎么打开?(关键词-消息通知)
  • ¥15 装 pytorch 的时候出了好多问题,遇到这种情况怎么处理?
  • ¥20 IOS游览器某宝手机网页版自动立即购买JavaScript脚本
  • ¥15 手机接入宽带网线,如何释放宽带全部速度