Home  >  Article  >  Backend Development  >  The img image address in the regular article content and the a connection address in the regular content_PHP tutorial

The img image address in the regular article content and the a connection address in the regular content_PHP tutorial

WBOY
WBOYOriginal
2016-07-13 17:06:55905browse

This example mainly talks about how to use regular expressions in php to get what we want. The above example is to take out all the link addresses and image addresses of the article content string, so we need to use regular expressions It's much more convenient.

The img image address in the regular article content and the a connection address in the regular content

$body ='loupan.com';
$Link ='fdasWebpage production tutorial';
$array ="aa,bb,cc,ee,ff,ss,ffa,ees,fde,ecd";
$v =explode( ',',$array);
if( is_array( $v) )
{
 
$vlen = sizeof( $v )-1;
$mt = mt_rand(1,$vlen);
$motype =$v[$mt];
}
else
{
$motype = $array;
}

$Link = preg_match_all('/ preg_match_all("/(src|SRC)=["|'| ]{0,}(Image/(.*).(gif|jpg|jpeg|png|bmp))/isU",$body,$img_array) ;

print_r( $img_array[2][0] );
echo '


';
echo $link_array[2][0];


This example mainly talks about how to use regular expressions in the PHP tutorial to get what we want. The above example is to take out all the link addresses and image addresses of the article content string. It is convenient for us to use regular expressions. Much more.
Original tutorial on this site, please indicate the source when reprinting: www.bKjia.c0m

www.bkjia.comtruehttp: //www.bkjia.com/PHPjc/630618.htmlTechArticleThis example mainly talks about how to use regular expressions in php to get what we want, as above The example is to put all the link address and image address of the article content string...
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