I have an array that has been serialized by php, the result is:
unserialize('a:2:{s:13:"custom_basket";a:1:{i:280583837398;a:4:{s:12:"product_name";s:0:"";s:8:"quantity";s:1:"1";s:5:"price";d:38.649999999999999;s:11:"description";a:7:{s:2:"id";s:12:"280583837398";s:3:"sku";s:0:"";s:4:"site";s:2:"UK";s:12:"condition_id";s:4:"1000";s:14:"transaction_id";s:12:"773563256018";s:8:"platform";s:4:"eBay";s:18:"order_line_item_id";s:25:"280583837398-773563256018";}}}s:6:"basket";a:0:{}}')
When I use my machine running php 5.3.5 I get:
Notice: unserialize() [function.unserialize]: Error at offset 46 of 405 bytes
When the dude next to me runs it on his machine running 5.3.6 he gets the array back out. Our server that runs php 5.3.4 also successfully unserializes the array.
The error that I get points to the first key in the second array i:280583837398
if I change this too s:12:"280583837398"
my machine can now unserialize the array successfully.
Does anyone have any idea why this is happening. I have no idea if it is the php version, I just noticed that I had a different version to the two successful machines so thought it worth mentioning.
I am running MAMP PRO on Snow Leopard if that helps.
Not sure if it's the version or not, but maybe the different versions handle ints differently. It seems like you understand s means a string of x length, hence s:12 is a string of length 12. But if php is trying to parse that as a 32 bit int, then it may fail.
280583837398 is a pretty big number, maybe your machine tries to fit it in an integer
which supports numbers up to 32 bits.
You probably need long
to store this one.
Thats all I can tell from this for now.