0

I have a field created by word press which contains data with the following structure.

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:"[email protected]"
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.

Any ideas on how I can parse this data, or access its properties in PHP.

I can not access this data through wordpress as my PHP script is part of something else.

3
  • Could you provide an example of how you want your array to look like? Commented Jul 3, 2019 at 10:59
  • 3
    unserialize this and check Commented Jul 3, 2019 at 10:59
  • 1
    It's serialized data. So unserialize it. Commented Jul 3, 2019 at 11:02

2 Answers 2

2

Seems like a serialized array. Try unserializing it to convert it back to normal, see example.

Sign up to request clarification or add additional context in comments.

1 Comment

Thats exactly what I needed. Thanks.
-1

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). maybe_unserialize is a wordpress default function to unserialize the array

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.