title: re arrange php associative array
body: <p>I have an array:</p>
  
  <pre><code>$example = array();
  
  $example ['one']   = array('first' =&gt; 'blue',
                             'second' =&gt; 'red');
  
  $example ['two']   = array('third' =&gt; 'purple',
                             'fourth' =&gt; 'green');
  
  $example ['three'] = array('fifth' =&gt; 'orange',
                             'sixth' =&gt; 'white');
  </code></pre>
  
  <p>Based on some input to the function, I need to change the order of the example array before the foreach loop processes my output:</p>
  
  <pre><code>switch($type)
  
  case 'a':
  //arrange the example array as one, two three
  break;
  
  case 'b':
  //arrange the example array as two, one, three
  break;
  
  case 'c':
  //arrange the example array in some other arbitrary manner
  break;
  
  foreach($example as $value){
          echo $value;
  }
  </code></pre>
  
  <p>Is there an easy way to do this without re-engineering all my code? I have a pretty indepth foreach loop that does the processing and if there was an easy way to simple re-order the array each time that would be really helpful.</p>