Well here's what I have so far. This code does function! It still needs some work but I've no work left in me this evening. I'm testing on my local it will work on a remote server.
<?php
function get_url_contents($url){
$crl = curl_init();
$timeout = 5;
curl_setopt ($crl, CURLOPT_URL,$url);
curl_setopt ($crl, CURLOPT_RETURNTRANSFER, 1);
curl_setopt ($crl, CURLOPT_CONNECTTIMEOUT, $timeout);
$ret = curl_exec($crl);
curl_close($crl);
return $ret;
}
$imagename = "VTKBC55";
$namesplit = "_";
$extension = ".jpg";
$imgsArray = array();
$image_dir = 'localhost/phpTest/images/';
$pageHTML = get_url_contents($image_dir);
$doc = new DOMDocument();
@$doc->loadHTML($pageHTML);
$imgTags = $doc->getElementsByTagName('a');
foreach ($imgTags as $img) {
$img = pathinfo($img->getAttribute('href'));
$imgsArray[] = $img['filename'];
echo "FILES: " . $img['filename'] . "<br />";
}
foreach($imgsArray as $img){
if(preg_match('/'.$imagename.$namesplit.'*?/',$img,$matches)){
echo "Matched: " . $img . '<br />';
print_r($matches);
echo "<br />";
}
}
?>