title: How to format var_export to php5.4 array syntax
body: <p>There are lots of questions and answers around the subject of valid php syntax from var outputs, what I am looking for is a quick and clean way of getting the output of <code>var_export</code> to use valid php5.4 array syntax.</p>
  
  <p>Given</p>
  
  <p>
  
  <pre><code>$arr = [
      'key' =&gt; 'value',
      'mushroom' =&gt; [
          'badger' =&gt; 1
      ]
  ];
  
  
  var_export($arr);
  </code></pre>
  
  <p>outputs</p>
  
  <pre><code>array (
    'key' =&gt; 'value',
    'mushroom' =&gt; 
    array (
      'badger' =&gt; 1,
    ),
  )
  </code></pre>
  
  <p>Is there any quick and easy way to have it output the array as defined, using square bracket syntax?</p>
  
  <pre><code>[
      'key' =&gt; 'value',
      'mushroom' =&gt; [
          'badger' =&gt; 1
      ]
  ]
  </code></pre>
  
  <p>Is the general consensus to use regex parsing? If so, has anyone come across a decent regular expression? The value level contents of the arrays I will use will all be <code>scalar</code> and <code>array</code>, no objects or classes.</p>