Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
我将此字符串存储在数据库列中:
O:8:"stdClass":2:{s:4:"type";s:5:"Point";s:11:"coordinates";a:2:{i:0;d:-23.5663719;i:1;d:-46.65284157;}}
我只想要中间的“坐标”:
-23.5663719,-46.65284157
有一种简单的方法可以在 PHP 中解析它以获得这个值吗?我试过 json_decode 但它没有用。
谢谢。
它不是 json 编码的,而是使用serialize().
serialize()
所以你要做的是:
$o = unserialize($str); // where $str is a string fetched from DB var_dump($o->coordinates);
参考: