looking for a php solution that finds a match for the following expression:
- The URL contains "http: //" (not necessarily starting with http: //) And
- The URL ends with a file extension from the array.
Example file extension array
$filetypes = array( jpg, gif, png, js, tif, pdf, doc, xls, xlsx, etc);
Here is the working code that I want to update using the above requirements:
This code currently works and only returns a URL containing "http: //", but I also want to include the second requirement.
$i = 0; $matches = false; foreach($all_urls as $index => $value) { if (preg_match('/http:/', $value)) { $i++; echo "[{$i}] {$value}<br>"; $matches = true; } }
source share