title: Notice (8): unserialize() [function.unserialize]: Error at offset 0 of 743 bytes in Cakephp for JSON Array serialize
body: <p>I am getting error:Notice (8): unserialize() [function.unserialize]: Error at offset 0 of 743 bytes when i try to display JSON encoded array in page.</p>
  
  <p>I am iterating all users in a foreach loop to get user details as array format. The array format looks like below:</p>
  
  <pre><code>$userDetails =
      Array
      (
          [id] =&gt; 12121212
          [enc_userid] =&gt; QWQWQWQWdssd
          [img_path] =&gt; http://192.168.1.XX/pjt/images/getuserphoto/SDSDSDSDSD/1/big/
          [msg_icon] =&gt; http://192.168.1.XX/pjt/img/sd/4a-icons/msg.png
          [rdd_icon] =&gt; http://192.168.1.XX/pjt/img/sd/4a-icons/invite.png
          [profile_path] =&gt; http://192.168.1.XX/pjt/user/sd/HJHJHJH
          [name] =&gt; XXX XXXXXXXXX
          [type] =&gt; IND
          [photo] =&gt; XXXXX.jpg
          [designation] =&gt; XXXX XXXXXXXXXXXXXXXXX
          [company] =&gt; XXXXXXXXXXXXXX Pvt Ltd
          [insid] =&gt; 
          [status] =&gt; 1
          [city] =&gt; XDXX, XXX,XXX
          [xxxx_id] =&gt; XXXX
      )
  </code></pre>
  
  <p>Then this array is serialized and displayed like:</p>
  
  <pre><code>echo serialize($userDetails);
  </code></pre>
  
  <p>The foreach loop looks like this:</p>
  
  <pre><code>$ui_array = array();
      foreach ($search_data as $key =&gt; $val) {
          $ui_array[] = unserialize($this-&gt;function_to_fetch_user_details($user_id));
      }
  echo json_encode($ui_array);exit;
  </code></pre>
  
  <p>But i am getting a false at beginning for JSON array like:</p>
  
  <pre><code>[false,{"id":"11168","enc_userid":"dsdsdsd","img_path":"http:\/\/192.168.1.dd\/sdsdsd\/images\/getuserphoto\/sdsdsd\/1\/big\/","msg_icon":"http:\/\/192.168.1.sd\/sdsd\/img\/sdheme\/icons\/msg.png" ...................
  </code></pre>
  
  <p>with error Notice (8): unserialize() [function.unserialize]: Error at offset 0 of 743 bytes.</p>
  
  <p>I am not understanding why this error is happening now as it was working perfect previously.
  Any help will be very helpful, Thank you!</p>