I have a script that uses foreach() like this: foreach ($var1 as $var2) { $statsarray=array(1 => $stats); print_r(array_values($statsarray)); } It goes through the foreach right and the print_r displays all the different stats, but there are in separate arrays, and I need them to be added together so they are all in the same array? Thank you.
Replace: $statsarray=array(1 => $stats); with: $statsarray[]=array(1 => $stats); the empty square brackets mean it's an array and to just append the right hand side of the = on the array. This means that as your code stands, $statsarray will become an array of arrays. A bigger problem is that you're using $stats, but it's not define anywhere!