tags:

views:

57

answers:

2

How can I extract the serialized values of a string stored in MySQL? The values look something like this: a:{s1:./... }. What is this?

+4  A: 

PHP has a serialize() function which turns any variable into a string like that.

echo serialize(array('foo', 3, array('bar' => 'BAR')));
// a:3:{i:0;s:3:"foo";i:1;i:3;i:2;a:1:{s:3:"bar";s:3:"BAR";}}

To return it to its original object, call unserialize().

nickf
thanks:-) . it helps me to find for perl ;)
joe
A: 

PHP::Serialization - simple flexible means of converting the output of PHP's serialize() into the equivalent Perl memory structure, and vice versa.

use PHP::Serialization qw(serialize unserialize);
my $encoded = serialize({ a => 1, b => 2});
my $hashref = unserialize($encoded);
joe