note 113761 added to function.strip-tags

From: Date: Thu, 28 Nov 2013 11:03:52 +0000
Subject: note 113761 added to function.strip-tags
Groups: php.notes 
Request: Send a blank email to php-notes+get-197647@lists.php.net to get a copy of this message
Fix for my Example2. If the text does not have allowed tags, $out_text is empty. Fix: <?php $out_text = ""; $ofs = 0; if(preg_match_all('#</?('.$tags_allowed.')\b([^><]*>)#sim', $in_text, $matches, PREG_OFFSET_CAPTURE)) { foreach($matches[0] as $tag) { $out_text .= htmlentities(substr($in_text, $ofs, $tag[1] - $ofs), ENT_NOQUOTES, "cp1251"); $out_text .= $tag[0]; $ofs = $tag[1] + strlen($tag[0]); } } $out_text .= htmlentities(substr($in_text, $ofs), ENT_NOQUOTES, "cp1251"); // end of text ?> ---- Server IP: 192.41.45.150 Probable Submitter: 81.5.80.154 ---- Manual Page -- http://php.net/manual/en/function.strip-tags.php Edit -- https://master.php.net/note/edit/113761 Del: integrated -- https://master.php.net/note/delete/113761/integrated Del: useless -- https://master.php.net/note/delete/113761/useless Del: bad code -- https://master.php.net/note/delete/113761/bad+code Del: spam -- https://master.php.net/note/delete/113761/spam Del: non-english -- https://master.php.net/note/delete/113761/non-english Del: in docs -- https://master.php.net/note/delete/113761/in+docs Del: other reasons-- https://master.php.net/note/delete/113761 Reject -- https://master.php.net/note/reject/113761 Search -- https://master.php.net/manage/user-notes.php

« previous php.notes (#197647) next »