title: In PHP, how can I convert an Array (dictionary) inside String variable to Array structure?
body: <p>I was looking for in Stack some solution to convert a string variable to an Array. The String variable contents this:</p>
  <pre><code>$myvar = 'array(&quot;a&quot; =&gt; array(&quot;b1&quot; =&gt; 1, &quot;b2&quot; =&gt; &quot;something&quot;), &quot;c&quot; =&gt; array(&quot;d1&quot; =&gt; 1))';
  </code></pre>
  <p>I want to convert as:</p>
  <pre><code>$myarray = array(
       &quot;a&quot; =&gt; array (   
           &quot;b1&quot; =&gt; 1, 
           &quot;b2&quot; =&gt; &quot;something&quot;
       ),
       &quot;c&quot; =&gt; array(&quot;d1&quot; =&gt; 1)      
  );
  </code></pre>
  <p>I was using <code>json_decode</code> after to convert my huge string to json, I used implode too ...</p>
  <p>Using eval, I recieve next error:</p>
  <p><code>Parse error: syntax error, unexpected '&lt;' in tabletocreate.php(51) : eval()'d code on line 1</code></p>
  <p>I used print_r($myvar);</p>
  <p>The idea it is I have an model inside a file model.php it is only a dictionary, I read this file inside a string and after to convert again an array, I do it because I need to generate a new database from this data, and I have the model for each catalog I need products, offer, ... obiously each model will be different but with the same structure of array, I wrote in the example</p>
  <p><strong>SOLUTION</strong></p>
  <p><a href="https://stackoverflow.com/users/3303195/faintsignal">faintsignal</a> resolved the solution in my case: <code>eval(&quot;\$myarray = &quot; . $myvar . ';');</code></p>