Last active
March 8, 2016 16:13
-
-
Save pvolyntsev/7c9834985186d15f72ff to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
/** | |
* Ответ на вопрос https://otvet.mail.ru/question/188212525 | |
*/ | |
$arr = array(1,2,3,0,4,5,6,0,8,9,10); // твой массив | |
$arr = array_reverse($arr); | |
$sum = 0; | |
foreach($arr as $element) | |
{ | |
if (0 == $element) | |
break; | |
$sum += $element; | |
} | |
echo $sum; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment