Reputation: 203
Lets say I have this data...just an example!
Before Serialize
array (size=2)
'first_name' => string 'Swashata'
'last_name' => string 'Ghosh'
After Serialize
a:2:{s:10:"first_name";s:8:"Swashata";s:9:"last_name";s:5:"Ghosh";}
So after the serialized data I'm going to unserialized it and get each value of the element of array to make it variable. The problem here is I want to get each element to make them a variable so that I can easily call them when I need it. Thanks! ahead.
Upvotes: 2
Views: 4245
Reputation: 326
After unserialize you need to call
$unserialized = unserialize($data);
echo $unserialized['last_name'];
not $unserialized[0]
You can use this as well
extract($unserialized);
echo $last_name;
Hope this is helpful.
Upvotes: 1
Reputation: 4676
I think you ask for extraction of key => value to variables..
So ..
$array = array(
'first_name' => 'Swashata'
'last_name' => 'Ghosh'
);
extract($array);
This will create variables called $first_name and $last_name with their values from your array..
Upvotes: 1
Reputation: 11987
Its in json format
Use json_decode()
to get the values from serialized data
$a = "serialized data";
$arr = json_decode($a);
print_r($arr);// will get back the result
Upvotes: 0