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

Image address expression in php regular string_PHP tutorial

WBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWB
Release: 2016-07-13 16:59:51
Original
920 people have browsed it

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 of this Website
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
Latest Issues
php data acquisition?
From 1970-01-01 08:00:00
0
0
0
PHP extension intl
From 1970-01-01 08:00:00
0
0
0
How to learn php well
From 1970-01-01 08:00:00
0
0
0
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template