Home  >  Article  >  Backend Development  >  Image address expression in php regular string_PHP tutorial

Image address expression in php regular string_PHP tutorial

WBOY
WBOYOriginal
2016-07-13 16:59:51843browse

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
 代码如下 复制代码

Array
(
    [0] => Array
        (
            [0] =>
        )

    [1] => Array
        (
            [0] => upfiles/2009/07/1246430143_1.jpg
        )

)

Copy code
Array
(
[0] => Array
(
                           [0] =>
)

[1] => Array
(
                                                                                                                                                                                                             )

http://www.bkjia.com/PHPjc/631306.html
www.bkjia.com
true
http: //www.bkjia.com/PHPjc/631306.htmlTechArticleIt is very easy to get the image address we want in the string, which is relatively For those who know regular expressions, let’s take a look below. The code is as follows...
Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn