I am using the following to parse an html page and return the images:
$html = file_get_html($url);
foreach($html->find('img') as $e){
$image = $e->src;
}
Ideally though I only want to show files with .jpg extension – I know I can probably use preg_match but is there a more efficient way?
NOTE: Just because a file has a JPEG-like extension does not mean that the content of the referenced file is actually JPEG data!
pathinfo()is the native PHP function you are looking for. Yes you can manipulate the string however you want, but if you are looking for the "right" way to do it then here it is: