Re: Serialization

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Ron: You need to use stripslashes() when passing a serialized string via HTTP requests.

<?php

error_reporting(E_ALL);
if (isset($_POST['serialArray'])) {
  $stripped = stripslashes($_POST['serialArray']);
  echo "<pre>";
  // Works
  $unserialized = unserialize($stripped);
  print_r($unserialized);
} else {
  echo "<form action='test.php' method='post'>";
  for($i=0;$i<10;$i++) {
    for($j=0;$j<10;$j++) {
      $aTest[$i][$j] = "Test $i $j";
    }
  }
  $sTest = serialize($aTest);
  echo "<input type='hidden' name='serialArray' value='$sTest'>";
  echo '<input type="submit" name="Submit" value="Submit">';
  echo $sTest;
  echo "</form>";
}

?>

--
PHP Windows Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


[Index of Archives]     [PHP Home]     [PHP Users]     [PHP Database Programming]     [PHP Install]     [Kernel Newbies]     [Yosemite Forum]     [PHP Books]

  Powered by Linux