php - array_push without array as parameter? -


this code

$items = array(1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17);     $numcols = 4;     $result = arrayvals($items,$numcols);     echo $result;     function arrayvals($items,$numcols) {         $minrow = floor(count($items)/$numcols);         $remaining = count($items) % $numcols;         $ccount = array();         ($i = 0;$i<$numcols;$i++) {             if ($i < $remaining) {                 array_push($ccount,$minrow+1);             } else {                 array_push($colcount,$minrow);             }         }         $liststring = '';         $count = 0;         ($i = 0;$i<count($ccount);$i++) {             $liststring = $liststring . "<ul>";             ($j = 0;$j<$ccount[$i];$j++) {                 $liststring = $liststring . '<li>' . $items[$count] . '</li>';                 $count = $count + 1;             }             $liststring = $liststring . '</ul>';         }         return $liststring; 

i getting the

warning: array_push() expects parameter 1 array, null given in c:\uniserver\www\rnd\test2\t2.php on line 20

how should solve

initialize $colcount array() before loop

$colcount=array(); 

Comments

Popular posts from this blog

javascript - Using jquery append to add option values into a select element not working -

Android soft keyboard reverts to default keyboard on orientation change -

jquery - javascript onscroll fade same class but with different div -