开发者

how can i access a variable defined inside a for each loop outside the loop?

开发者 https://www.devze.com 2023-02-20 00:01 出处:网络
Here is my code... foreach ($relatedStories->getResults() as $story): $total+=$story->getEstimation();

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;).

0

精彩评论

暂无评论...
验证码 换一张
取 消