List Info

Thread: note 76045 added to function.strip-tags




note 76045 added to function.strip-tags
user name
2007-06-27 10:44:45
I noticed some problems with the strip_selected_tags()
function below, sometimes big chunks of contents where
suppressed... 
Here is a modified version that should run better.

<?php
function strip_selected_tags($text, $tags = array())
{
    $args = func_get_args();
    $text = array_shift($args);
    $tags = func_num_args() > 2 ?
array_diff($args,array($text))  : (array)$tags;
    foreach ($tags as $tag){
       
while(preg_match('/<'.$tag.'(|W[^>]*)>(.*)</'.
$tag .'>/iusU', $text, $found)){
            $text = str_replace($found[0],$found[2],$text);
        }
    }

    return
preg_replace('/(<('.join('|',$tags).')(|W.*)/>)/iusU
', '', $text);
}

?>
----
Server IP: 217.174.196.197
Probable Submitter: 82.101.58.161
----
Manual Page -- 
http://www.php.net/manual/en/function.strip-tags.php
Edit        -- https://master
.php.net/note/edit/76045
Del: integrated  -- h
ttps://master.php.net/note/delete/76045/integrated
Del: useless     -- http
s://master.php.net/note/delete/76045/useless
Del: bad code    -- htt
ps://master.php.net/note/delete/76045/bad+code
Del: spam        -- https:/
/master.php.net/note/delete/76045/spam
Del: non-english -- 
https://master.php.net/note/delete/76045/non-english
Del: in docs     -- http
s://master.php.net/note/delete/76045/in+docs
Del: other reasons-- https://mast
er.php.net/note/delete/76045
Reject      -- https://mast
er.php.net/note/reject/76045
Search      -- https://
master.php.net/manage/user-notes.php

-- 
PHP Notes Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub
.php


[1]

about | contact  Other archives ( Real Estate discussion Medical topics )