note 89309 added to function.strip-tags

From: Date: Tue, 03 Mar 2009 11:22:30 +0000
Subject: note 89309 added to function.strip-tags
Groups: php.notes 
Request: Send a blank email to php-notes+get-151376@lists.php.net to get a copy of this message
Strip tags doesn't work fine if we have '<' symbol in the string followed immediately by any letter. but it doed work fine if there is a space after '<' symbol. e.g. strip_tags('<p>1<4</p>'); //won't work fine strip_tags('<p>1 < 4</p>'); //will work fine to solve this problem, I used a simple logic. This code will replace '<' by html char, if it not a part of html tag. My version of strip_tags is as follow: function my_strip_tags($str) { $strs=explode('<',$str); $res=$strs[0]; for($i=1;$i<count($strs);$i++) { if(!strpos($strs[$i],'>')) $res = $res.'&lt;'.$strs[$i]; else $res = $res.'<'.$strs[$i]; } return strip_tags($res); } ---- Server IP: 203.199.69.133 Probable Submitter: 121.242.9.66 ---- Manual Page -- http://www.php.net/manual/en/function.strip-tags.php Edit -- https://master.php.net/note/edit/89309 Del: integrated -- https://master.php.net/note/delete/89309/integrated Del: useless -- https://master.php.net/note/delete/89309/useless Del: bad code -- https://master.php.net/note/delete/89309/bad+code Del: spam -- https://master.php.net/note/delete/89309/spam Del: non-english -- https://master.php.net/note/delete/89309/non-english Del: in docs -- https://master.php.net/note/delete/89309/in+docs Del: other reasons-- https://master.php.net/note/delete/89309 Reject -- https://master.php.net/note/reject/89309 Search -- https://master.php.net/manage/user-notes.php

« previous php.notes (#151376) next »