Get highest numbered file and create next one
<p>I have a folder that contains files named standard_xx.jpg (xx being a number)</p>

<p>I would like to find the highest number so that I can get the filename ready to rename the next file being uploaded.</p>

<p>Eg. if the highest number is standard_12.jpg 
$newfilename = standard_13.jpg</p>

<p>I have created a method to do it by just exploding the file name but it isn't very elegant</p>

<pre><code>$files = glob($uploaddir.'test-xrays-del/standard_*.JPG');
$maxfile = $files[count($files)-1];
$explode = explode('_',$maxfile);
$filename = $explode[1];
$explode2 = explode('.',$filename);
$number = $explode2[0];
$newnumber = $number + 1;
$standard = 'test-xrays-del/standard_'.$newnumber.'.JPG';
echo $newfile;
</code></pre>

<p>Is there a more efficient or elegant way of doing this?</p>
