天天看點

php二維數組增加最後一個元素在後面$uids = M('user_pid')->where("pid = 2")->field("uid")->select(); $count = count($uids); foreach ($uids as $k => $val) { -----判斷如果是循環的最後一次就加上這個元素    if ($k == $count-1) {         $uids[] = array('uid' => 1000);     } }

$uids = M('user_pid')->where("pid = 2")->field("uid")->select();

$count = count($uids);

foreach ($uids as $k => $val) {

-----判斷如果是循環的最後一次就加上這個元素

   if ($k == $count-1) {

        $uids[] = array('uid' => 1000);

    }

}