title: php random order from a foreach
body: <p>I have some foreach, this could work well </p>
  
  <pre><code>foreach ($umm as $data) {
          echo '&lt;img src="'.$data-&gt;picture.'" /&gt;';
          echo  $data-&gt;id;
  }
  </code></pre>
  
  <p>Now I want shuffle the foreach. I tried:</p>
  
  <pre><code>foreach (shuffle($umm) as $data) {
          echo '&lt;img src="'.$data-&gt;picture.'" /&gt;';
          echo  $data-&gt;id;
  }
  </code></pre>
  
  <p>AND</p>
  
  <pre><code>foreach ($umm as $data) {
          $rand_pic[] = $data-&gt;picture;
          $rand_id[] = $data-&gt;id;
  }
  $ran = shuffle($rand_id);
  foreach($ran as $new){
      echo '&lt;img src="'.$new-&gt;picture.'" width="100" /&gt;';
      echo $new-&gt;id;
  }
  </code></pre>
  
  <p>All these caused <code>Warning: Invalid argument supplied for foreach()</code> in second <code>foreach</code>. How to random order from a foreach?</p>