Это мой кодarray_push без массива в качестве параметра?
$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();
for ($i = 0;$i<$numCols;$i++) {
if ($i < $remaining) {
array_push($cCount,$minRow+1);
} else {
array_push($colCount,$minRow);
}
}
$listString = '';
$count = 0;
for ($i = 0;$i<count($cCount);$i++) {
$listString = $listString . "<ul>";
for ($j = 0;$j<$cCount[$i];$j++) {
$listString = $listString . '<li>' . $items[$count] . '</li>';
$count = $count + 1;
}
$listString = $listString . '</ul>';
}
return $listString;
я получаю
Предупреждение: array_push() ожидает параметр 1, чтобы быть массивом, нуль приведены в C: \ UniServer \ WWW \ RnD \ Test2 \ t2.php на линии 20
, как я должен решить
'$ colCount'! ==' $ cCount' –
определить '$ ColCount = массив() ; 'выше' for loop'. – Saty
Что такое '$ colCount' в' array_push ($ colCount, $ minRow), ' –