Array_diff sorunu çözemedi

0 Cevap
$j[0]='is';
$j[1]='for';
$diff = array_diff($uniqdesc, $j); 
foreach($diff as $find){

echo $find."</br>";

$uniquedesc is an array from a string of words. I need to print out all the uncommon words. The above code is working fine and eliminating 'is' 'for'

Şimdi bir metin dosyasındaki tüm ortak kelimeleri saklanır. Ve ben kelimelerin herhangi bir dize gelen bu ortak kelimeleri ortadan kaldırmak gerekir.

Ama kod çalışmak için görünmüyor. Bunu çözmek için?

   $common = file_get_contents('commonwords.txt'); 
$commonArray = explode(" ",$common);
sort($commonArray);
$q=0;
array_unique($commonArray);
$jay=array_unique($commonArray);
foreach($jay as $k){
$j[$q]=(string)$k;
$q=$q+1;
}
$q=0;
for($q=0;$q<20;$q++)
{
echo $j[$q];// This is for testing. It printed the first 20 strings correctly.
}

$diff = array_diff($uniqdesc, $j); 
foreach($diff as $find){

echo $find."</br>";

0 Cevap