i am trying to unserialize string that is stored in mysql table.
following is the string stored in mysql table.
a:3:{s:15:\"purchase_amount\";d:500;s:4:\"more\";d:7;s:4:\"less\";d:11.5;}
at the time of insertion i had written following code.
addslashes(serialize(array('purchase_amount' => $values['purchase_amount'], 'more' => $values['transportaion_cost_gretter'], 'less' => $values['transportaion_cost_lesser'])))
At retrieval i had written followin code.
unserialize(stripslashes($row->getTransportaionCost()));
i am getting following error.
Notice: unserialize() [function.unserialize]: Error at offset 5 of 98 bytes
EDIT:
i tried json_encode and json_decode...
following is json data in mysql table
{"purchase_amount":500,"more":7,"less":11.5}
Following is the json decode in php.
var_dump(json_decode($row->getTransportaionCost())); //null
can any one tell me what is the problem ?