问题
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";}
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.
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.
回答1:
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 );
来源:https://stackoverflow.com/questions/56581702/how-can-i-convert-this-wordpress-json-entry-into-php-array