title: Json_encode/decode in php
body: <p>I have an array on view <code>$all_set</code> which contain some ids.now i want to pass this array in controller using form submit.for that i used the j son encode and decode.</p>
  
  <p>on my view:</p>
  
  <pre><code>&lt;?php $all_set=json_encode($all_set); ?&gt;
  
  &lt;input type="hidden" name="all_set" value="&lt;?php echo serialize($all_set); ?&gt;"&gt;
  </code></pre>
  
  <p>the above value contains(as i saw in page source):</p>
  
  <pre><code>&lt;input type="hidden" name="all_set" value="s:26:"{"0":"1","5":"2","13":"3"}";"&gt;
  </code></pre>
  
  <p>Now on controller:</p>
  
  <pre><code>$result=$this-&gt;input-&gt;post('all_set');
  
             $result= unserialize($result);
             $result=json_decode($result);
             print_r($result); die;
  </code></pre>
  
  <p>This gives me error and i am not getting any array on controller.
  Error:</p>
  
  <pre><code>Message: unserialize() [function.unserialize]: Error at offset 0 of 5 bytes
  </code></pre>
  
  <p>Why is this so? please Help.</p>