Reputation: 4901
I'm not entirely sure what to call this, and I had a tough time searching for helpful results.
I have a wordpress plugin for a contact form that inputs the data into the database like this.
a:37:{i:0;a:8:{s:2:"id";s:2:"20";s:4:"slug";s:11:"enfant-kind";
s:4:"name";s:13:"options_other";s:0:"";s:9:"parent_id";s:2:"21";s:5:"value";s:0:"";}}
This is only part of it and it's pretty long. I'm wondering how I can read this using PHP to break apart the form fields and inputs.
Upvotes: 0
Views: 74
Reputation: 18281
http://www.php.net/manual/en/function.unserialize.php
That should turn that string into a object.
$data = unserialize($raw_data_from_db);
For anecdotal info, a:37 means an array thats 37 elements long, i:0 is for integer 0, s:'s are strings and their size. There's two more letters but as long as you are using serialize and unserialize, you should be good to go.
Upvotes: 1