Reputation: 1
I'm calling a function that creates a 2-dimensional array
$rowMM = array(array($incrementeCnt, $yyyy, $mmDesc, $flname,$uname,$room,
$newcol[0],$newcol[1],$newcol[2],$newcol[3], $newcol[4], $newcol[5]));
Also I used and gives me the same result
$rowMM = array($incrementeCnt, $yyyy, $mmDesc, $flname,$uname,$room,
$newcol[0],$newcol[1],$newcol[2],$newcol[3], $newcol[4], $newcol[5]);
I tested it with 12 entries by doing a print_r
in my function that shows everything, but when I return to the calling PHP page print_r
only shows the last entry of the array from calling page.
$getArray=createArray()
print_r($getArray) // shows the last entry of the array
Upvotes: 0
Views: 102
Reputation: 5224
My guess is you need:
$rowMM[] = array($incrementeCnt, $yyyy, $mmDesc, $flname,$uname,$room,
$newcol[0],$newcol[1],$newcol[2],$newcol[3], $newcol[4], $newcol[5]);
because you are in a loop and print_r
ing in the function. You then use return $rowMM
after the loop. $rowMM
overwrites on every iteration though so it only has the last reference.
Upvotes: 1