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"
    
    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?

悬赏问题

  • ¥20 绿盟安全扫描--检测到目标站点存在javascript框架库漏洞
  • ¥30 Android STD快速启动
  • ¥15 如何使用simulink建立一个永磁同步直线电机模型?
  • ¥30 天体光谱图的的绘制并得到星表
  • ¥15 PointNet++的onnx模型只能使用一次
  • ¥20 西南科技大学数字信号处理
  • ¥15 有两个非常“自以为是”烦人的问题急期待大家解决!
  • ¥30 STM32 INMP441无法读取数据
  • ¥15 R语言绘制密度图,一个密度曲线内fill不同颜色如何实现
  • ¥100 求汇川机器人IRCB300控制器和示教器同版本升级固件文件升级包