How can I read strings like that? What do they mean?
a:10:{i:0;s:7:"default";i:1;s:8:"failsafe";i:2;s:4:"foaf";i:3;s:4:"ical";i:4;s:2:"js";i:5;s:4:"json";i:6;s:6:"opendd";i:7;s:3:"php";i:8;s:3:"rss";i:9;s:3:"xml";}
I've seen a lot of systems which use strings like that, stores it in the database and parse to get the values. How can I parse them?
Thanks.
This is a serialized string. Look at the results of var_dump(unserialize())
. It is NOT a valid JSON-formatted string (json_decode()
will return null).
If you want to actually "read" it without unserializing it, you can see "a:10"
means array with 10 indices. "i:0"
means "index zero" and is semicolon-separated with the corresponding value ("s:7"
is a string of length 7). The values are comma separated. Classes can also be serialized.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With