title: php loop random product from the list
body: <p>i have product list, from witch i need to display four items randomly.</p>
  
  <pre><code>&lt;?php 
  
  // my product list
  function productlistX {
      $array = array( 
  
          $product {$name = 'product name', $link = 'product link', $img = "product image"};
          $product {$name = 'product name', $link = 'product link', $img = "product image"};
          $product {$name = 'product name', $link = 'product link', $img = "product image"};
          $product {$name = 'product name', $link = 'product link', $img = "product image"};
          $product {$name = 'product name', $link = 'product link', $img = "product image"};
          $product {$name = 'product name', $link = 'product link', $img = "product image"};
          $product {$name = 'product name', $link = 'product link', $img = "product image"};
          $product {$name = 'product name', $link = 'product link', $img = "product image"};
          $product {$name = 'product name', $link = 'product link', $img = "product image"};
          $product {$name = 'product name', $link = 'product link', $img = "product image"};
          $product {$name = 'product name', $link = 'product link', $img = "product image"};
          $product {$name = 'product name', $link = 'product link', $img = "product image"};
          $product {$name = 'product name', $link = 'product link', $img = "product image"};
          $product {$name = 'product name', $link = 'product link', $img = "product image"};
          $product {$name = 'product name', $link = 'product link', $img = "product image"};
  
      )
  
      // need to display 4 random products from the array above 
      foreach  {
          echo "&lt;li&gt;".$name . $link . $img . "&lt;/li&gt;"
      }
  }
  
  // display these random products in my ajax tab (products.php?order=mytab)
  $data['mytab'] = $productlistX;
  
  if (isset($data[$_GET['order']])) { 
      echo $data[$_GET['order']];
  } 
  ?&gt;
  </code></pre>
  
  <p>so as you see, i have list ant need to display only four items form the list randomly. </p>
  
  <p>thanks in advance!</p>