简体   繁体   English

PHP:将此数据结构转换为关联数组

[英]PHP: Converting this data structure into an associative array

I have a field created by word press which contains data with the following structure. 我有一个由word press创建的字段,其中包含具有以下结构的数据。

a:16:{s:7:"country"
s:14:"United Kingdom"
s:7:"form_id"
s:2:"35"
s:9:"timestamp"
s:10:"1560869327"
s:7:"request"
s:0:""
s:8:"_wpnonce"
s:10:"125"
s:16:"_wp_http_referer"
s:1:"/"
s:17:"ajaxy-umajax-mode"
s:8:"register"
s:10:"first_name"
s:5:"xxxxx"
s:9:"last_name"
s:5:"xxx"
s:10:"user_email"
s:28:"xxx@xxx.co.uk"
s:7:"Company"
s:16:"xxx LTD"
s:12:"phone_number"
s:10:"0123456789"
s:8:"user_url"
s:20:"http://www.test.com"
s:15:"company_address"
s:18:"999 LockSmith Lane"
s:12:"display_name"
s:12:"XXXX"
s:10:"user_login"
s:10:"xxx123"
}

I want to convert this to an array so I can read the properties of it. 我想将其转换为数组,以便可以读取其属性。

I tried converting it to json but its not json. 我尝试将其转换为json,但不是json。

Any ideas on how I can parse this data, or access its properties in PHP. 关于如何解析此数据或在PHP中访问其属性的任何想法。

I can not access this data through wordpress as my PHP script is part of something else. 我无法通过wordpress访问此数据,因为我的PHP脚本是其他内容的一部分。

Seems like a serialized array. 好像是一个序列化数组。 Try unserializing it to convert it back to normal, see example . 尝试对其进行反序列化以将其转换回普通格式, 请参见example

This is Actually not a json.This is an array in serialized format you can just unserilize it by using this function maybe_unserialize($YOUR_ARRAY) . 这实际上不是json。这是序列化格式的数组,您可以通过使用此函数maybe_unserialize($YOUR_ARRAY)序列化。 maybe_unserialize is a wordpress default function to unserialize the array maybe_unserialize是wordpress的默认函数,用于反序列化数组

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM