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

PHP replaces image alt and title tags_PHP tutorial

WBOY
Release: 2016-07-13 10:45:54
Original
1320 people have browsed it

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...
source:php.cn
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
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template