How come unserialize isn't restoring my array? See code below..
// prints a:1:{s:8:"txn_type";s:32:"recurring_payment_profile_cancel";}
echo $item['response'];
// prints nothing
print_r(unserialize($item['response']));
I understand why the print_r($response) gives me nothing
** edit - I noticed this
Notice: unserialize() [function.unserialize]: Error at offset 6 of 2797 bytes in /home/reitinve/public_html/action/doc.php on line 13
What does that mean?
Is it possible $item['response']
contains some whitespace before or after it?
Check strlen($item['response'])
gives you 61.
Edit: It seems to work with whitespace at the end, but whitespace at the start will make it fail to unserialize.
Edit: that error message means either you have a LOT of whitespace (almost 2kb of it), or $item['response']
is being changed between the echo
and the unserialize
works for me just fine. are you sure that $item['response']
is a string? yeah, seems like leading whitespaces.
and on your dev server php never should give you 'nothing'. it should be configured to produce all errors, warnings and notices. also you can use http://php.net/var_dump instead of print_r as it give you more information.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With