array_merge() 函數把兩個或多個數組合並為一個數組。
如果鍵名有重復,該鍵的鍵值為最後一個鍵名對應的值(後面的覆蓋前面的)。如果數組是數字索引的,則鍵名會以連續方式重新索引。
例如:
$news=M('news'); $sql="select count(a.news_id) as count_news,a.menu_id,b.pid from news a left join menu b on a.menu_id=b.menu_id where a.is_pass=0 group by a.menu_id ;"; $count=$news->query($sql); $text_check=M('text_check'); $sql2="select count(a.check_id) as count_news,a.menu_id,b.pid from text_check a left join menu b on a.menu_id=b.menu_id where a.is_pass=0 group by a.menu_id ;"; $count2=$text_check->query($sql2); dump($count);exit dump($count2);exit; dump(array_merge($count,$count2));exit;
查看本欄目