It is very easy to get the image address we want in a string. This is compared to friends who know regular expressions. Let’s take a look below.
代码如下 | 复制代码 |
$str=''; $pattern="/<[img|IMG].*?src=['|"](.*?(?:[.gif|.jpg]))['|"].*?[/]?>/"; preg_match_all($pattern,$str,$match);print_r($match); ?> |
The result shows:
The code is as follows
|
Copy code | ||||
[1] => Array
(
)