I have passed a value from one page to another in array. I can extract first two vars by explode but I can\'t get the third value which is formed in an array out.
This i
Using serialize is definitely the key to getting this to work, but base64_encode() is the ideal way to make it less obfuscated. When you only use serialize, then you get semicolons, commas, double quotes, single quotes, and several other characters that could cause problems when you pass them through to your script that reassembles it.
For instance, after serializing an array, you will get this, like Sidux pointed out
a:3:{i:0;s:4:"toto";i:1;s:4:"titi";i:2;a:2:{i:0;s:4:"coco";i:1;s:4:"cici";}}
When you add base64_encode to the mix you will get an easier value to work with.
YTozOntpOjA7czo0OiJ0b3RvIjtpOjE7czo0OiJ0aXRpIjtpOjI7YToyOntpOjA7czo0OiJjb2NvIjtpOjE7czo0OiJjaWNpIjt9fQ==
With this, you can easily send/receive your saved array without any trimming, adding of slashes, etcetera.
Assuming you send your data this way, your new code will look like this
$user_rate=$_POST['user_rate'];//15000|ss|Array
list($total,$promo,$rate)=explode("|",$user_rate);
$rate = unserialize( base64_decode($rate) );
Now, $rate
is a functional array