0

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 دامنه";}}
1
  • @GYaN, that was the OP's first question ("what's type of this code"). Then responding "What is your above code" is not very helpful. Check the answer below. Commented Jan 13, 2018 at 10:22

1 Answer 1

1

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...

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

1 Comment

@Mahdi98 I don't understand your question

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.