Home > php教程 > php手册 > body text

php替换图片alt与title标签

WBOY
Release: 2016-06-13 09:48:47
Original
789 people have browsed it

要做到替换所有图片或者是连接的alt title我们必须用到正则函数,下面看一个替换图片alt实例

*/

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

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


在 subject 中搜索 pattern 模式的匹配项并替换为 replacement。如果指定了 limit,则仅替换 limit 个匹配,如果省略 limit 或者其值为 -1,则所有的匹配项都会被替换。

 


过滤所有html 标签
*/

$html_body ="
fdafdsa
内容
";
preg_replace("/(?)(w+)([^>]*>)/e",
             "'1'.strtoupper('2').'3'",
             $html_body);


   
//更多详细内容请查看:php教程er/php-function/33530.htm">http://www.bKjia.c0m/phper/php-function/33530.htm

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 Recommendations
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!