PHP - Display 4 most recent images from directory
<p>Very new to PHP. I have sucessfully got this piece of code working to display 4 images from a directory, however it shows the <strong>first</strong> 4 images by name (001.png, 002.png, 003.png and 004.png) which are the lowest numbers and happen to be the least recently uploaded:</p>

<pre><code>&lt;?php
$pictures = glob("directory/*.png"); 
for( $i=0; $i&lt;=3; $i++ ){ 
echo "&lt;img src=\"".$pictures[$i]."\" /&gt;"; 
}  
?&gt;
</code></pre>

<p>I am looking to change that to get the 4 most recently uploaded in a directory by name.
In other words, I would like to display the <strong>last</strong> 4 images with the highest number.
I have tried this below however I am getting Parse error: syntax error, unexpected T_VARIABLE on line 4</p>

<pre><code>&lt;?php
$pictures = glob("directory/*.png"); 
$no_pictures = count($pictures)-1 
$limit = $no_pictures-3 
for( $i = $no_pictures; $i &gt;= $limit; $i--; ){ 
echo "&lt;img src=\"".$pictures[$i]."\" /&gt;\n"; 
}  
?&gt;
</code></pre>

<p>Any help is appreciated. Thanks for your time.</p>
