I need to create an array, in which first two columns are filled from MySQL DB, while other 1440 columns are filled with zeros. Please see my code.
First two columns are filled correctly, while zeros(0,1440) results in Array[0]. As a results the number of columns is 3 (Array[3]) instead of 1442.
What’s wrong with it?
$query2="SELECT resID, resTitle FROM my_db.resources;";
$result2=DatabaseConnector::ExecuteQueryArray($query2);
$i=0;
$resAlloc = array();
foreach ($result2 as $row):
$resAlloc[$i] = array($row['resID'],$row['resTitle'],zeros(0,1440));
$i++;
endforeach;
// Generate an array of zeros
function zeros($rowCount, $colCount){
$matrix = array();
for ($rowIndx=0; $rowIndx<$rowCount; $rowIndx++){
$matrix[] = array();
for($colIndx=0; $colIndx<$colCount; $colIndx++){
$matrix[$rowIndx][$colIndx]=0;
}
var_dump(memory_get_usage());
}
return $matrix;
}
How about:
?