New line in serialised array PHP
<p>When taking data from a HTML form and storing a value in a serialised array if there is a new line the serialisation is going wrong with mysql_real_escape_string.</p>

<p>for example this outputs a string of the wrong length also plus the new line has been removed</p>

<pre><code>$value="new\r\nline";

mysql_real_escape_string($value);


$array=array();
$array[0]=$value;

$array=serialize($array);

echo $array;
</code></pre>

<p>prints out a:1:{i:0;s:9:"new line";}</p>
