Home >Backend Development >PHP Tutorial >PHP replaces image alt and title tags_PHP tutorial

PHP replaces image alt and title tags_PHP tutorial

WBOY
WBOYOriginal
2016-07-13 10:45:541329browse

To replace all images or connected alt titles we must use regular functions. Let’s look at an example of replacing image alt

*/

preg_replace('#alt="[^"]*"#i','alt="".$title.""',$str);

/*
mixed preg_replace (mixed pattern, mixed replacement, mixed subject [, int limit])


Searches subject for a match of pattern and replaces it with replacement. If limit is specified, only limit matches are replaced; if limit is omitted or has a value of -1, all matches are replaced.


Filter all html tags
*/

$html_body ="
fdafdsa
content
";
preg_replace("/(]*>)/e",
"'1'.strtoupper('2').'3'",
                  $html_body);


 
//For more details, please see: php tutorialer/php-function/33530.htm">http://www.bKjia.c0m/phper/php-function/33530.htm

www.bkjia.comtruehttp: //www.bkjia.com/PHPjc/632986.htmlTechArticleTo replace all pictures or connected alt titles, we must use regular functions. Let’s look at a replacement picture. alt instance*/ preg_replace('#alt=[^]*#i','alt=.$title.',$str); /* m...
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