This is for a chat page. I have a $string = \"This dude is a mothertrucker\". I have an array of badwords: $bads = array(\'truck\', \'shot\', etc)
1) The simplest way:
if ( in_array( 'eleven', array('four', 'eleven', 'six') ))
...
2) Another way (while checking arrays towards another arrays):
$keywords=array('one','two','three');
$targets=array('eleven','six','two');
foreach ( $targets as $string )
{
foreach ( $keywords as $keyword )
{
if ( strpos( $string, $keyword ) !== FALSE )
{ echo "The word appeared !!" }
}
}