Reputation: 1463
So I have learned that when a file is uploaded in Drupal, you get the fid
in return, which you can find in the files table in the database. I keep seeing strings that look like the following, and I was hoping someone could explain each part.
a:2:{i:0;s:4:"9201";i:1;s:4:"9206";}
I can see that here the fids are 9201 and 9206, respectively, and I'm assuming the i:0
and i:1
have to do with the order the files were uploaded. But what is the rest of it?
Also, if it matters, this particular string was the result of a print_r from form data with a multi-file upload field.
Upvotes: 1
Views: 296
Reputation: 36955
It's the return value from PHP's serialize()
function when passed an array equivalent to the following:
array(
0 => "9201",
1 => "9206"
)
You can reverse the process using unserialize()
.
Drupal (like a lot of applications) saves some settings in a serialized string rather than creating database tables for every possible setting.
EDIT
Just to add, a:2
means the type of variable to follow is an array with 2 elements and s:4
means the type of variable is a string with 4 characters. i
denotes an integer type.
Upvotes: 2