如何将这个WordPress JSON条目转换为PHP数组? [英] How can I convert this WordPress JSON entry into PHP array?
问题描述
我正在使用一个界面来将WordPress应用程序中的数据加载到我自己的数据库中.一张表记录随附于此:
I am working on an interface to load data from a WordPress application into my own database. One table record comes with this:
a:6:{i:0;s:2:"39";i:1;s:2:"88";i:2;s:2:"89";i:3;s:2:"53";i:4;s:2:"54";i:5;s:2:"91";}
我知道它代表什么,我认为它是一种JSON格式,但是我不知道如何将该字符串转换为可读的PHP数组.
I know what this is representing and I think its a kind of JSON format, but I don't know how to convert this string into a readable PHP array.
我已经尝试过像explode(';')
这样的explode()
,但是结果没有任何意义.
I´ve tried to explode()
something like explode(';')
, but the result doesn't make any sense.
有没有人看过这个并且可以帮助我? 谢谢.
Have anyone seen this and can help me? Thanks.
推荐答案
这不是JSON字符串.这是一个序列化的数组.
That's not a JSON string. It's a serialized array.
要再次将序列化的字符串转换为常规数组,请使用反序列化:
To make the serialized string into a regular array again, use unserialize:
$serialized_array = 'a:6:{i:0;s:2:"39";i:1;s:2:"88";i:2;s:2:"89";i:3;s:2:"53";i:4;s:2:"54";i:5;s:2:"91";}';
$unserialized_array = unserialize($serialized_array);
var_dump( $unserialized_array );
这篇关于如何将这个WordPress JSON条目转换为PHP数组?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!