This is the data extracted from some databases: user|a:11:{s:3: "UID"; s:1: "8"; s:5: "Email"
I want to convert it to an array, how to achieve it?
Reply content:
This is the data extracted from some databases: user|a:11:{s:3: "UID"; s:1: "8"; s:5: "Email"
I want to convert it to an array, how to achieve it?
This question ... How to say it ... Full is a slot point instead of giving people a sense of how to not know ah ...
First of all... You cannot deposit the original in 数组 any way ... 数据库
No BLOB matter TEXT ... Not even ...
Want to save ... The array must be converted to the form of a string ... This process is called 序列化 ...
Serialization does not adhere to the algorithm ... You can use any of the methods that can convert arrays and strings to each other ...
Top-floor data ... is an array that has been processed after this ...
There is an old saying that the bell needs to be called.
Want to get the original data ... To see how this array is handled by the algorithm ...
Although I don't quite understand what the meaning of this storage is ... In my opinion this way is very inexplicable ...
But I think the people who have realized this storage ... Must realize the data read ...
Save and Load are always in pairs in a normal situation ... Reading the code is sure to help ...
Hello, I'm a lazy egg. Split Line
Of course, if you don't even have the mind to read the code ... Then I can also guess a realization to you ...
I can only guess from the words in your attic. Not necessarily accurate ...
For reading you can also try ... Not recommended for modifying the original content inside the database ...
!--? php/* the BLOB data read from database ... */$string = ' Put_your_data_ Here '; * * I guess string always start with name| ... */$parts = explode (' | ', $string, 2);/* Now we'll trying to restore, parts ... */$ $parts [0] = unserialize ($part S[1]);/* registered a new variable which name as same as 1st part ... */print_r ($user); The last variable name is the first one in your original data | Before the content ...
The example is $user because the data provided on your penthouse begins with the user ...
I'm not sure if there's only one array in your complete data ... Or there are many ...
If there are a lot of problems that involve | Escaping inside the array ... It will be more troublesome ...
Not see the full content ... In a simple way guess that's it ... Hope to help you ...
The uses PHP's built-in serialization algorithm serialize () ... There's no harm in looking at it ...
Well ... Unconsciously wrote a lot of ... Just go to bed and have a little activity ... Healthy and good sleep!