PHP Serialize & Unserialize
<p>I have problem with Unserialize which return nothing after getting it from $_POST. I post a simple array from a form and I could see double quotes been added to the serialized string. I tried stripslashes before serialzing and before unserializing, but the result is the same with no output. I have turned of magic_quotes_gpc in php.ini and again no luck. When I hardcode the values in unserialize by adding "\" manually gave me the desired string, So I tried with addslashes and again left with nothing. Please help me resolve this.</p>

<pre><code>&lt;?php


$tmp = $_POST["strVid"];

$myNewArray = unserialize($trp);
print_r($myNewArray);

$myArray = array('key1'=&gt;'value1', 'key2'=&gt;'value2');
$serialized = serialize($myArray);
?&gt;

&lt;form  onsubmit="return validate(this)" action="test_serialize.php" method="post"&gt;
&lt;input type="hidden" name="strVid1" value="this is mega shit"/&gt;
&lt;input type="hidden" name="strVid" value="&lt;?php echo $serialized; ?&gt;"&gt;
&lt;input type="Submit" name="next" value="Next"/&gt;

&lt;/form&gt;
</code></pre>

<p>Updated...</p>

<p>After Serialize: a:2:{s:4:"key1";s:6:"value1";s:4:"key2";s:6:"value2";}</p>

<p>After stripslashes of Serialize: a:2:{s:4:"key1";s:6:"value1";s:4:"key2";s:6:"value2";} </p>

<p>when I add \ manually</p>

<p>$myNewArray = unserialize("a:2:{s:4:\"key1\";s:6:\"value1\";s:4:\"key2\";s:6:\"value2\";} ");</p>

<p>I get the output as Array ( [key1] => value1 [key2] => value2 ) </p>

<p>Thanks</p>
