I'm new in PHP
I have an array like this
$suspiciousList = array(
array ("word" => "badword1", "score" => 400, "type" => 1),
array ("word" => "badword2", "score" => 250, "type" => 1),
array ("word" => "badword3", "score" => 400, "type" => 1),
array ("word" => "badword4", "score" => 400, "type" => 1));
I have problems when users input words with spaces like (badw ord1, b adword2, etc.), or a user may input like (b a d w o r d 1)
How can I detect or search for combinations from the array (dictionary)?
My idea is to make every word become an array split by spaces.
$this->suspiciousPart[] = $word;
I'm write following function
public function deepDetect2() {
for($i=0;$i<sizeof($this->suspiciousPart);$i++) {
$word = "";
for($j=$i;$j<sizeof($this->suspiciousPart);$j++) {
$word .= $this->suspiciousPart[$j];
//var_dump($word);
if(strpos(in_array($word, $this->suspiciousList), $word) !== false) {
if($this->detect($word) == true) {
$i++;
} else {
$j++;
}
} else {
$i++;
}
}
}
}
Anybody have other ideas how to do this?
Thanks