我有2阵列在我的代码,就像下面的图所示:和array_diff不起作用(PHP)
<?php
$kalimat = "I just want to search something like visual odometry, dude";
$kata = array();
$eliminasi = " \n . ,;:-()?!";
$tokenizing = strtok($kalimat, $eliminasi);
while ($tokenizing !== false) {
\t $kata[] = $tokenizing;
\t $tokenizing = strtok($eliminasi);
}
$sumkata = count($kata);
print "<pre>";
print_r($kata);
print "</pre>";
//stop list
$file = fopen("stoplist.txt","r") or die("fail to open file");
$stoplist;
$i = 0;
while($row = fgets($file)){
\t $data = explode(",", $row);
\t $stoplist[$i] = $data;
\t $i++;
}
fclose($file);
$count = count($stoplist);
//Cange 2 dimention array become 1 dimention
for($i=0;$i<$count;$i++){
for($j=0; $j<1; $j++){
\t $stopword[$i] = $stoplist[$i][$j];
}
} \t
//Filtering process
$hasilfilter = array_diff($kata,$stopword);
var_dump($hasilfilter);
?>
$禁用词包含一些停用词像附着在http://xpo6.com/list-of-english-stop-words/
我想要做的是:我想检查是否保存数组$ kata中存在的元素,并且它不存在于数组$ stopword
所以我想删除数组$ kata和$ stopword中存在的所有元素。 我读了一些建议使用array_diff,但不知何故,它不适用于我。真的需要你的帮助:(谢谢
你希望我们猜测'$ kata','$ stopword'的内容是什么? –
我已经编辑它。抱歉。 – Berlian