title: Php get jpg file from a folder as array
body: <p>help me to get files from a folder in array.
  I am trying to get all jpg file name in <code>array</code> from a folder <code>images</code>.
  and after that use <code>rand</code> to change css background Randomly.</p>
  
  <p>JPG files from a folder in arry;</p>
  
  <pre><code>$images=array("image1.jpg", "image2.jpg");
  </code></pre>
  
  <p>then use the <code>rand</code> to load images randomly</p>
  
  <pre><code>echo '&lt;style&gt;body{background:url('.$images[array_rand($images)].')no-repeat;';
  </code></pre>