looking for a php solution that will find a match the following expression:
- URL contains "http://" (not necessarily begins with http://) AND
- URL ends with a file extension from an array.
Example of file extension array
$filetypes = array(
jpg,
gif,
png,
js,
tif,
pdf,
doc,
xls,
xlsx,
etc);
Here is the working code I wish to update with the above requirements:
Right now, this code works and returns only URL's that contain "http://" but i want to include the second requirement as well.
$i = 0;
$matches = false;
foreach($all_urls as $index => $value) {
if (preg_match('/http:/', $value)) {
$i++;
echo "[{$i}] {$value}<br>";
$matches = true;
}
}
'http://mattressandmore.com/wp-content/themes/barberry/js/fresco.js'- I just realised the file extension may end with apostrophe as well