视<代码>连续<>/代码”的格式而定,视具体情况而定,需要一些 t:
<?php
$content = http://www.example.com/images/image001.jpg
http://www.example.com/images/image002.jpeg
http://www.example.com/images/list001.jpg
http://www.example.com/images/image003.png
http://www.example.com/images/bad002.png
http://www.example.com/images/image004.gif
http://www.example.com/images/words003.jpg ;
preg_match_all( !http://.+.(?:jpe?g|png|gif)!Ui , $content, $matches);
preg_match_all( /S+(list|of|bad|words)S+/i , $content, $bads);
$filtered = array_values(array_diff($matches[0], $bads[0]));
print_r($filtered);
?>
<<>Output>:
Array
(
[0] => http://www.example.com/images/image001.jpg
[1] => http://www.example.com/images/image002.jpeg
[2] => http://www.example.com/images/image003.png
[3] => http://www.example.com/images/image004.gif
)