Check if file is JPG


I am creating a simple script that uses scandir() to generate a XML with the images list inside a folder. My doce is:

$dir = "images/"; //You could add a $_GET to change the directory 
$files = scandir($dir); 
echo "<?xml version='1.0'?>";
echo "<list>";
foreach($files as $key => $value){ 
echo "<image>".$value."</image>"; //You could add an icon in here maybe, a link to the file/directory, or a link to list files in that directory 
echo "</list>";

The only problem, or lets call bug, I found in this script is that if I have some other file with another extension the script will list it too.

What I need is a way to check if the value is a jpg. Can anyone give me a hint?