<! doctype html public "- // w3c // dtd xhtml 1.0 transitional // en" "http://www.w3.org/tr/xhtml1/dtd/xhtml1-transitional.dtd">
<html xmlns = "http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv = "content-type" content = "text / html; charset = gb2312" />
<title> php tutorial to extract article content image address regular expression </ title>
</ head>
<body>
<form id = "form1" name = "form1" method = "post" action = "">
<p>
<label for = "body"> </ label>
<textarea name = "body" id = "body" cols = "45" rows = "5"> </ textarea>
</ p>
<p>
<input type = "submit" name = "button" id = "button" value = "Submit" />
</ p>
</ form>
</ body>
</ html>
<?
if ($ _post)
{
$ body = $ _post ['body'];
preg_match_all (/ src | src) = ["| '|] {0,} ((. *). (gif | jpg | jpeg | png | bmp)) / isu", $ body, $ array);
if ($ array)
{
echo 'get the picture address';
print_r ($ array);
}
else
{
echo 'article content does not exist in the effective image address';
}
}
/ * Test input
Here is www.jzread.com to provide you with a regular access to the contents of the article in the picture address code is as follows
<img src = / get_pic / 2010/03 / 20100811004403298.gif />
fdsafdsafsa
result:
Get image address array
(
[0] => array
(
[0] => src = / get_pic / 2010/03 / 20100811004403298.gif
)
[1] => array
(
[0] => src
)
[2] => array
(
[0] => /get_pic/2010/03/20100811004403298.gif
)
[3] => array
(
[0] => http://www.jzread.com/a
)
[4] => array
(
[0] => gif
)
)
?>