Smarty Forum Index Smarty
WARNING: All discussion is moving to https://reddit.com/r/smarty, please go there! This forum will be closing soon.

Summa elementov massiva

 
This forum is locked: you cannot post, reply to, or edit topics.   This topic is locked: you cannot edit posts or make replies.    Smarty Forum Index -> Language: Russian
View previous topic :: View next topic  
Author Message
datcent
Smarty n00b


Joined: 06 Oct 2010
Posts: 1

PostPosted: Wed Oct 06, 2010 10:22 am    Post subject: Summa elementov massiva Reply with quote

Pogaluista pomogite v reshenii takoy problemy:

Est masiv cyfr, zapisannyi v peremennyiy, kolichestvo cifr ne fiksirovanno v masive. Nugno v novyiu peremennyiy poshitat arifmeticheskyiy symmy elementov massiva.

Pytalsya nayti otvet na etot vopros na sayte, no bezrezultatno, ochen nadeiys na pomosh.

Zaranee blagodariy
Back to top
View user's profile Send private message
developpa
Smarty n00b


Joined: 27 Nov 2010
Posts: 1

PostPosted: Sat Nov 27, 2010 7:04 pm    Post subject: Reply with quote

Code:
1. <?php
2.
3. // определим некоторый массив случайных чисел
4. $arr = array(145, 21, 46, 213, 114, 7, 84, 91, 302, 501, 37); //
хватит
5.
6. foreach ($arr as $k => $v) {
7. echo "\$arr[$k] = $v<br>"; // вывод значения очередного
элемента массива
8. }
9.
10. $summ = 0;
11. foreach ($arr as $v) {
12. $sum += $v;
13. }
14. echo "Сумма элементов массива равна $sum";
15.
16. ?>
[/code]
Back to top
View user's profile Send private message Visit poster's website
SiZE
Smarty Rookie


Joined: 15 Sep 2010
Posts: 13

PostPosted: Mon Jan 24, 2011 7:32 am    Post subject: Reply with quote

{assign var="array_sum" value=$array|@array_sum}
Back to top
View user's profile Send private message
pekaba
Smarty n00b


Joined: 25 Jan 2012
Posts: 2
Location: Moscow

PostPosted: Thu Jan 26, 2012 1:16 pm    Post subject: Reply with quote

SiZE wrote:
{assign var="array_sum" value=$array|@array_sum}


i think, right will be

{assign var="array_sum" value=$array|$array_sum>3}
Back to top
View user's profile Send private message
optmmservice
Smarty n00b


Joined: 29 Feb 2012
Posts: 1
Location: http://m-mservice.ru

PostPosted: Wed Feb 29, 2012 4:09 pm    Post subject: Reply with quote

Где учишься то, что с массивами не справиться?)
Back to top
View user's profile Send private message
Display posts from previous:   
This forum is locked: you cannot post, reply to, or edit topics.   This topic is locked: you cannot edit posts or make replies.    Smarty Forum Index -> Language: Russian All times are GMT
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © 2001, 2005 phpBB Group
Protected by Anti-Spam ACP