sanitizing a string before serializing and inserting to db
<p>I'm facing an odd problem....</p>

<p><code>$string</code> is user input</p>

<pre><code>$log = serialize(array('string' =&gt; $string);
</code></pre>

<p>example: "test" would be</p>

<blockquote>
  <p>"string";s:4:"test";</p>
</blockquote>

<p>However problems arise when the user submits quotes and some other characters like ;
Of course I escape the string first, but the serialized data cannot be unserialized.</p>

<p><code>htmlentities</code> before submitting to db wouldn't work either since <code>;</code> messes up the data...</p>

<p>Any suggestions?</p>

<p>Please don't tell me to create db fields and not use <code>serialize()</code></p>
