简体   繁体   中英

How to use two preg_replace

Knowing that:

$str = $row_ultimos_posts['conteudo'];

I have this code:

echo preg_replace("/<iframe[^>]+\>/i", "",$str);

And I have this code:

preg_replace ("/<img(.+?)>/", "",$str);

How can I use both codes? How to merge it to work?

preg_replace("/<iframe[^>]+\>/i", "",preg_replace ("/<img(.+?)>/", "",$str));

You can basically wrap them in a function like

function foo($str)
{

$str = preg_replace("/<iframe[^>]+\>/i", "",$str);
$str = preg_replace ("/<img(.+?)>/", "",$str);

return $str;

}

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM