简体   繁体   中英

How to use preg_replace and strip_tags together in PHP

Is it possible to use preg_replace and strip_tags together on the same string?

I'm trying to remove HTML tags and all non_alpha_numeric characters from a string using the following :

<?=strip_tags (preg_replace('/[^\da-z]/i', ' ', $line['features']))?>,

This is currently removing the non_alpha characters but leaving the tags minus the brackets/parenthesis.

Anybody help?

your preg_replace is removing the "<" ">" values so strip_tags doesn't recognise them as tags,

if you reverse the functions

<?=preg_replace('/[^\da-z]/i', ' ', strip_tags($line['features']));?>

it should work

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