Ivan
Ivan

Reputation: 1

print_r of an array doesn't print the values

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

Answers (1)

user3783243
user3783243

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_ring 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

Related Questions