title: Unserialize sometimes returns false
body: <p>I have this function in my application:</p>
  
  <pre><code>public function direct($theTree)
  {
      $aTreeRoot = preg_replace('!s:(\d+):"(.*?)";!se', "'s:'.strlen('$2').':\"$2\";'", $theTree);
      return unserialize($aTreeRoot);
  }
  </code></pre>
  
  <p>It should never return false but in the error logs the error keep occuring which says it returned false.</p>
  
  <p>However, I cannot replicate the error in my application. I'm trying to every possible way but it always works.</p>
  
  <p>Is there something wrong with the function?</p>
  
  <p>The <code>$theTree</code> comes from session.</p>
  
  <p><em>Edit:</em> The regex is there because: <a href="http://php.net/manual/en/function.unserialize.php" rel="noreferrer"><code>unserialize</code></a> - Search for my regex there in the comments. It's supposed to solve a problem.</p>