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 is my array:

```
$user_rate=$_POST['user_rate'];//15000|ss|Array
list($total,$promo,$rate)=explode("|",$user_rate);

```

So I get:

```
$total=15000;
$promo=ss;
$rate=Array;

```

While Array comes from the previous page by looping the daily rate and put in an array. And I need to know what each rate is, so I wrote:

```
foreach($rate as $val){
echo "$val<br>";
}

```

But it shows nothing. How can I get this?

Updated : This is the code before the var is sent.

```
echo "
<tr>
<td align=\"right\" colspan=\"3\">Total</td>
<td align=\"right\"><label for=\"promo_3\"><input type=\"radio\" name=\"user_rate\" id=\"promo_3\" value=\"$ss_total|ss|$cost_ss\" />&nbsp;<u><b>".number_format($ss_total)."</b></u></label></td>
<td align=\"right\"><label for=\"promo_1\"><input type=\"radio\" name=\"user_rate\" id=\"promo_1\" value=\"$net_total|nc|$cost_nr\" checked/>&nbsp;<u><b>".number_format($net_total)."</b></u></label></td>
</tr>";

```

**AND THIS FORMAT OF VALUE CANNOT CHANGE BECAUSE I NEED IT FOR A LATER JAVASCRIPT EXTRACT**

While **$cost\_ss** and **$cost\_nr** are derived from database query looping.

```
while($rec=mysql_fetch_array($result)){
$cost_ss[]=$rec['rate_ss'];
$cost_nr[]=$rec['rate_nr'];
}

```
['https://Stackoverflow.com/questions/16817377', 'https://Stackoverflow.com', 'https://Stackoverflow.com/users/1620626/']
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
Hi i think that i understand you probleme, when you passe and array from as string try to "serialize" it and "unserialize" it in the other page, for exemple :

```
$array = serialize(array('toto', 'titi', array('coco', 'cici')));

```

will give you somthing like this

`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";}}`

and if you use`unserialize($array);` it will give you your array back