Craig Van Sant
Craig Van Sant

Reputation: 149

How do I decode data in mysql field that is in this format?

I have fields in my database that I need to decode or view in a more simple format. I'm not sure what method was used to create this format though I've seen it before. This is data from a web form in a MySQL table. What do I use in PHP or MySQL to decode this when I retrieve it from the database?

a:10:{s:10:"First Name";s:10:"cvsgjsrhlw";s:9:"Last Name";s:10:"cvsgjsrhlw";s:7:"Address";s:26:"http://www.tlneepxlni.com/";s:4:"City";s:7:"Atlanta";s:5:"State";s:2:"AL";s:8:"Zip Code";s:0:"";s:9:"Best time";s:7:"Mid-day";s:6:"Other2";s:8:"cqoeqipd";s:14:"Procedure face";s:18:"Laser Hair Removal";s:4:"when";s:22:"In the next 4 months.";}

Upvotes: 1

Views: 494

Answers (3)

Ray
Ray

Reputation: 41428

This is a serialized array. Use:

 $data_array = unserialize($data_from_db);

Upvotes: 1

scrblnrd3
scrblnrd3

Reputation: 7416

This is serialize()'d code. It is a way to multiple data types as plain text. You can convert it back to a php object with unserialize($data)

If you are writing new code, I would recommend using json_encode() instead

Upvotes: 1

zerkms
zerkms

Reputation: 254886

It's a built in php serialization

You need to use unserialize

Upvotes: 1

Related Questions