$a = []; $i = 0; foreach ($notice_list as $key => $value) { # code... if($key%2 ==0){ $i++; } $a[$i][]=$value; }