Jump to content

ezpickinz

Members
  • Posts

    4
  • Joined

  • Last visited

ezpickinz's Achievements

Newbie

Newbie (1/5)

0

Reputation

  1. So here's where I'm at now. The trouble is that it will match anything after filename_ even when the extension changes. How can I say: preg_match('/^'.$imagename.$namesplit. ' *? $img[extension] /' ,$this_img_name,$matches) ???? foreach ($imgTags as $img) { $img = pathinfo($img->getAttribute('href')); $imgsArray[] = array('filename'=>$img['filename'],'extension'=>$img['extension']); //echo "FILES: " . $img['filename'] . "<br />"; } print_r($imgsArray); echo "<br /><br /><br /><br /><br />"; foreach($imgsArray as $img){ $this_img_name = $img['filename']. $img['extension']; if(preg_match('/^'.$imagename.$namesplit.'/',$this_img_name,$matches)){ echo "Matched: " . $img['filename'] . '.' . $img['extension'] . '<br />'; print_r($matches); echo "<br />"; } }
  2. 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 />"; } } ?>
  3. ...Also, there is no index for the image dir so it can be read as a page. I think I may have just answered my own Q. Please don't stop thinking for me though. If you have a solution I'd love to hear it...
  4. I have an image name (pic01.jpg) and the directory it lives in on the remote server ( I also have permission to be there). I know that in many cases there will be a small stack of images that together make a set like, pic01.jpg, pic01_blue.jpg, pic01_yk7z.jpg, pic01_8m.jpg... I know I can use curl to get a response code but then I'd have to know the name of the file first. I believe this will be a small job using Regex. Trouble is every time I begin to read about Regex my eyes glaze over so I'm really not sure. Your help is greatly appreciated. John
  5. Yeah that was pretty corny but hey, where else you gonna get away with it?! Okay all joking aside... Hello, my name is John and I need help and just like everyone else, I have a serious project burning here and need answers now. LOL ... sorry all, very very long couple of weeks here and I'm on the home stretch! I will be posting a new question thread as soon as I find a home for it...
×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.