陣列我有這個功能,我得到這個錯誤Zend的PHP函數的錯誤 - 警告:array_merge():參數#1不
Warning: array_merge(): Argument #1 is not an array in
$diff = array_merge($followers['ids'], $friends['ids']);
然後
Invalid argument supplied for foreach() in
功能:
public function addtosystemAction(){
$this->_tweeps = new Application_Model_Tweeps();
$http = new Zend_Http_Client();
$http->setUri('http://api.twitter.com/1.1/followers/ids.json?cursor=-1&screen_name=testuser');
$followers = Zend_Json::decode($http->request()->getBody(), true);
$http->setUri('http://api.twitter.com/1.1/friends/ids.json?cursor=-1&screen_name=testuser');
$friends = Zend_Json::decode($http->request()->getBody(), true);
$diff = array_merge($followers['ids'], $friends['ids']);
$resultArray = array();
foreach ($diff as $id){
if(FALSE == $this->_tweeps->checkExisting($id)){
$resultArray[] = $id;
if(count($resultArray) == 50){
break;
}
}
}
任何提示,爲什麼我得到這個錯誤?
您是否嘗試過調試之前是空的?使用'var_dump($ followers ['ids'])來檢查;'如果是數組或不是。 – Rikesh