php - Creating a multi dimensional array - is there a better way than this -
i have code
foreach ($objworksheet->getrowiterator() $row) { $output[] = array(); //adding blank array end doesn't seem //advance array pointer manually. $test = end($output); $celliterator = $row->getcelliterator(); foreach ($celliterator $cell) { //specifically bit $output[key($output)][] = $cell->getvalue(); } }
but don't how i've found current key using
$output[key($output)][] = $cell->getvalue();
is there better approach?
why don't use variable?
foreach ($objworksheet->getrowiterator() $row) { $cells = array(); foreach ($row->getcelliterator() $cell) { $cells[] = $cell->getvalue(); } $output[] = $cells; }
Comments
Post a Comment