title: How to pass a serialized array to Symfony2 Command
body: <p>I create a symfony2 command with one argument.
  This argument is the result of serialize($array) function.</p>
  
  <p>But, inside the command I'm not able to unserialize() the received argument, i always got an error:</p>
  
  <pre><code>Notice: unserialize(): Error at offset 5 of 48 bytes in ...
  </code></pre>
  
  <p>This is a example of the array i want to send to the command:</p>
  
  <pre><code>$array = array('key1' =&gt; '$value1', 'key2' =&gt; '$value2')
  </code></pre>
  
  <p>When i serialize the array (serialize($array)) this is the result:</p>
  
  <pre><code>a:2:{s:4:"key1";s:7:"$value1";s:4:"key2";s:7:"$value2";} 
  </code></pre>
  
  <p>I was thinking: maybe the problem is due to double quotes in the string (remember, is to send to a command as parameter), then, i apply the addslashes function:</p>
  
  <pre><code>addslashes(serialize($array)) 
  </code></pre>
  
  <p>This is the result:</p>
  
  <pre><code>a:2:{s:4:\"key1\";s:7:\"$value1\";s:4:\"key2\";s:7:\"$value2\";}
  </code></pre>
  
  <p>but im still receiving the same error when i try to unserialize the string inside the command execute() function.</p>
  
  <p>Any idea?</p>