2014-04-18 90 views
0

我有2個數組;array_intersect()不再工作?

$friends = array(); 
$idpens = array(); 

然後我得到朋友的ID從Facebook爲$朋友

$result = $this->facebook->api("/me/friends"); 
     foreach($result['data'] as $index => $friend){ 
       $friends[] = $friend['id']; 
      } 

,並在數據庫

$idpencipi=$this->persion->getid(); 
     foreach($idpencipi as $index => $idpen){ 
       $idpens[] = $idpen['fb_id']; 
      } 

打印得到ID:

print_r($friends): Array (
[0] => 1009167810 
[1] => 106309886180996 
[2] => 1677624156 
[3] => 1818586059 
[4] =>100004421164127) 


print_r($idpens): Array (
[0] => 100004421164127 
[1] => 106309886180996 
[2] => 2345679543234) 

但是當我使用array_intersect ()

print_r(array_intersect($idpens,$friends)); 

輸出:

Array() 

我能做些什麼?

+0

[_ Cananot Reproduce_](https://eval.in/138094) –

回答

0

我已覈對這個code.Its工作正常。 我想你的數組中有一個越來越重寫,這就是爲什麼它無法找到共同的元素。

注意:請修剪輸入數據。這可能是因爲不需要的空間。

請仔細檢查本文或發佈您的整個腳本代碼。

+0

如果您發現此答案有用,請不要忘記接受或評分 – Maverick