Really the easiest thing is going to be to create a new array and sum as you go. Something like:
$sums = array();
for($i=0;$i<count($alllevels); $i++)
{
if(!array_key_exists($alllevels[$i], $sums))
$sums[$alllevels[$i]] = 0;
$sums[$alllevels[$i]] += $testarray[$i];
}
print_r($sums);
Then you can loop through $sums and display it you please.
While that is a solution, the better is to take a look at how you originally construct the arrays and reconstruct it. Either sum it up as you go (like above) or add array elements to the key so your array looks like:
["Level 0"] => Array (
[0] => 50,
[1] => 60
),
["Level 1"] => Array (
[0] => 30,
[1] => 50,
[2] => 70
)
With a setup like that you could easily do:
foreach($alllevels as $level => $values)
{
echo $level.' - '.array_sum($values).'<br />';
}
Either way will work.