Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/php/276.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Php 这是什么样的数据,它能转换成JSON吗_Php_Json_Database_Wordpress - Fatal编程技术网

Php 这是什么样的数据,它能转换成JSON吗

Php 这是什么样的数据,它能转换成JSON吗,php,json,database,wordpress,Php,Json,Database,Wordpress,我正在开发cargo wordpress插件,shipping history页面将以下数据存储在数据库的meta_值字段中。有人知道这是什么类型的数据吗?我应该如何使用它或更改为JSON s:815:"a:4:{i:0;a:7:{s:4:"date";s:10:"2018-03-08";s:4:"time";s:7:"1:00 am";s:8:"location";s:4:"test";s:12:"updated-name";s:7:"wpcargo";s:10:"updated-by";i:

我正在开发cargo wordpress插件,shipping history页面将以下数据存储在数据库的meta_值字段中。有人知道这是什么类型的数据吗?我应该如何使用它或更改为JSON

s:815:"a:4:{i:0;a:7:{s:4:"date";s:10:"2018-03-08";s:4:"time";s:7:"1:00 am";s:8:"location";s:4:"test";s:12:"updated-name";s:7:"wpcargo";s:10:"updated-by";i:2;s:7:"remarks";s:1:"1";s:6:"status";s:16:"Shipment Left US";}i:1;a:7:{s:4:"date";s:10:"2018-03-08";s:4:"time";s:7:"1:00 am";s:8:"location";s:4:"test";s:12:"updated-name";s:7:"wpcargo";s:10:"updated-by";i:2;s:7:"remarks";s:1:"1";s:6:"status";s:10:"Processing";}i:2;a:7:{s:4:"date";s:10:"2018-09-12";s:4:"time";s:7:"7:27 pm";s:8:"location";s:4:"test";s:12:"updated-name";s:7:"wpcargo";s:10:"updated-by";i:2;s:7:"remarks";s:1:"1";s:6:"status";s:10:"In Transit";}i:3;a:7:{s:4:"date";s:10:"2018-09-12";s:4:"time";s:7:"7:31 pm";s:8:"location";s:10:"tofindthis";s:12:"updated-name";s:7:"wpcargo";s:10:"updated-by";i:2;s:7:"remarks";s:1:"1";s:6:"status";s:10:"In Transit";}}";

这看起来像一个序列化数组

要将其转换为JSON,您需要先对其进行反序列化,然后对其进行编码


将回显json编码字符串,其中,
$arr
是反序列化数组。

请注意,输入字符串已序列化两次:a:4部分是序列化数组,但它被包装在s:815中。因此,您需要将它通过PHP的unserialize()两次,以获得可以进行json_编码的数组。@Rup我试过了。第二个unserialize()捕获到错误。第一个很好
echo json_encode($arr);