Jump to content

eregi help cheers.


redarrow

Recommended Posts

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

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

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

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.