Arrays certainly are useful. If you’re dealing with associative data, there’s no better tool for the job. Sometimes, you’ll run into cases where it would be useful to store an entire array in a field in a database. It’s not something you want to do if you can avoid it, by structuring your database’s tables more efficiently for example, but there are cases where it’s unavoidable.
That’s where serialize() comes in. You can pass an array to the function, and it will return a string that is essentially the array flattened and mashed down. You can then unserialize() it to obtain the full array once again.
<?php
$the_array = array( "Lorem", "Ipsum", "Dolor" );
$serialized = serialize($the_array);
print $serialized;
?>
This will output a:3:{i:0;s:5:"Lorem";i:1;s:5:"Ipsum";i:2;s:5:"Dolor";}
. It’s the whole array in string form, suitable for insertion into a database field. It will work with more complex arrays, of course, but simple is better for examples.