Reputation: 145
how can I make an array by the following serialized string:
a:2:{i:1;a:4:{s:5:"index";s:1:"1";s:4:"name";s:22:"برای تست اول";s:6:"amount";s:6:"600000";s:11:"description";s:31:"فقط برای یک دامنه";}i:2;a:4:{s:5:"index";s:0:"";s:4:"name";s:22:"برای تست دوم";s:6:"amount";s:5:"70000";s:11:"description";s:37:"مجوز برای 2 تا 3 دامنه";}}
Upvotes: 0
Views: 51
Reputation: 29912
This is called "serialization"
unserialize('a:2:{i:1;a:4:{s:5:"index";s:1:"1";s:4:"name";s:22:"برای تست اول";s:6:"amount";s:6:"600000";s:11:"description";s:31:"فقط برای یک دامنه";}i:2;a:4:{s:5:"index";s:0:"";s:4:"name";s:22:"برای تست دوم";s:6:"amount";s:5:"70000";s:11:"description";s:37:"مجوز برای 2 تا 3 دامنه";}}');
will return your array.
In particular this string is telling you
a:2
this will be an array of two elements
i:2;a:4:
this is the first index (weirdly is not zero indexed) that will contain an array of four elements
s:5:"index";s:1:"1"
this is the first element of "innermost" associative array, with a key named index
(a string of 5 chars basically) and its values "1" (a string with only one char)
and so on...
Upvotes: 1