redarrow Posted February 18, 2007 Share Posted February 18, 2007 Hi there all advance thanks i am finishing a project and this code wont work any idears please cheers. <?php $blog="hi there i am redarrow < how's you"; if(eregi("^\<,\>,\?,\@,\*,\(,\),\=,\-,\_,\\,\,\exit;\,\;\,\" ",$blog)){ echo "bad word"; } ?> Link to comment https://forums.phpfreaks.com/topic/39055-eregi-help-cheers/ Share on other sites More sharing options...
Orio Posted February 18, 2007 Share Posted February 18, 2007 Can you define what are you trying to filter? Orio. Link to comment https://forums.phpfreaks.com/topic/39055-eregi-help-cheers/#findComment-188103 Share on other sites More sharing options...
redarrow Posted February 18, 2007 Author Share Posted February 18, 2007 orio trying to filter text box for a blog entry with the followeing charecters. "<",">","?","@","*","(",")","=","-","_","\",","exit;" eregi wont work or preg_match <?php $word=" hi there i < am redarrow"; $w=array("<",">","?","@","*","(",")","=","-","_","\",","exit;" ); foreach($w as $blog){ if(eregi('^$blog',$word)){ echo "bad word"; exit; } } ?> Link to comment https://forums.phpfreaks.com/topic/39055-eregi-help-cheers/#findComment-188111 Share on other sites More sharing options...
redarrow Posted February 18, 2007 Author Share Posted February 18, 2007 now this examlpe gives a error without the wrong charecter but with it's ok weried. <?php $word=" hi there i < am redarrow"; $w=array("<",">","?","@","*","(",")","=","-","_","\",","exit;" ); foreach($w as $blog){ if(eregi($blog,$word)){ echo "bad word"; exit; }else{}; } ?> Link to comment https://forums.phpfreaks.com/topic/39055-eregi-help-cheers/#findComment-188119 Share on other sites More sharing options...
Orio Posted February 18, 2007 Share Posted February 18, 2007 Yoo can use strpos(), and it's faster too: <?php $sentence = "hi there i < am redarrow"; $w = array("<",">","?","@","*","(",")","=","-","_","\",","exit;" ); foreach($w as $char) { if(strpos($sentence, $char) !== FALSE) { die("Bad sentence"); } } echo "Your sentence is good "; ?> Orio. Link to comment https://forums.phpfreaks.com/topic/39055-eregi-help-cheers/#findComment-188126 Share on other sites More sharing options...
redarrow Posted February 18, 2007 Author Share Posted February 18, 2007 Thank you solved never seen it before now cheers. dam i missed that one lol. Link to comment https://forums.phpfreaks.com/topic/39055-eregi-help-cheers/#findComment-188131 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.