如何在循环外的每个循环中访问a内定义的变量?

Here is my code...

foreach ($relatedStories->getResults() as $story):
    $total+=$story->getEstimation();
endforeach;

$$relatedStories is an array of values.im summing the attribute estimation to total. Now i need to access the total value outside. How can i do so????

Define variable $total outside the loop. ($total = 0;).