doupo2241 2018-08-17 09:12
浏览 124
已采纳

获取mysql数据库中特定的值部分

First of all, I am sorry if I sound pretty newby about this, I am actually an UX Researcher, that is currently working on some front-end project that requeres some backend developing. Since there is no backend dev, I have to do it myself.

Currently I am trying to get a specific part of this string in the value:

meta_key: links

meta_value: a:2:{s:3:"url";s:26:"https://YOURLINK.COM/LINKMEHARD";s:5:"title";s:4:"Film";}

What I need to call in php is the value of s:26 (the link). I would have tried to find out that myself, hut I have no idea how that term of the value in the value is called.

  • 写回答

1条回答 默认 最新

  • duanba5777 2018-08-17 09:21
    关注

    The "meta_value" string that you have provided is actually serialized PHP (http://php.net/serialize).

    You can simply take the value that you have retrieved from the database and call unserialize() on it to turn it back into an object or array.

    From what you've provided, you should be able to do something like:

    $unserialized = unserialize($row['meta_value']);
    echo $unserialized['url']; // should produce "https://YOURLINK.COM/LINKMEHARD"
    
    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?

悬赏问题

  • ¥15 HFSS 中的 H 场图与 MATLAB 中绘制的 B1 场 部分对应不上
  • ¥15 如何在scanpy上做差异基因和通路富集?
  • ¥20 关于#硬件工程#的问题,请各位专家解答!
  • ¥15 关于#matlab#的问题:期望的系统闭环传递函数为G(s)=wn^2/s^2+2¢wn+wn^2阻尼系数¢=0.707,使系统具有较小的超调量
  • ¥15 FLUENT如何实现在堆积颗粒的上表面加载高斯热源
  • ¥30 截图中的mathematics程序转换成matlab
  • ¥15 动力学代码报错,维度不匹配
  • ¥15 Power query添加列问题
  • ¥50 Kubernetes&Fission&Eleasticsearch
  • ¥15 報錯:Person is not mapped,如何解決?