|
Smarty
WARNING: All discussion is moving to https://reddit.com/r/smarty, please go there! This forum will be closing soon. |
|
View previous topic :: View next topic |
Author |
Message |
datcent Smarty n00b
Joined: 06 Oct 2010 Posts: 1
|
Posted: Wed Oct 06, 2010 10:22 am Post subject: Summa elementov massiva |
|
|
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 |
|
developpa Smarty n00b
Joined: 27 Nov 2010 Posts: 1
|
Posted: Sat Nov 27, 2010 7:04 pm Post subject: |
|
|
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 |
|
SiZE Smarty Rookie
Joined: 15 Sep 2010 Posts: 13
|
Posted: Mon Jan 24, 2011 7:32 am Post subject: |
|
|
{assign var="array_sum" value=$array|@array_sum} |
|
Back to top |
|
pekaba Smarty n00b
Joined: 25 Jan 2012 Posts: 2 Location: Moscow
|
Posted: Thu Jan 26, 2012 1:16 pm Post subject: |
|
|
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 |
|
optmmservice Smarty n00b
Joined: 29 Feb 2012 Posts: 1 Location: http://m-mservice.ru
|
Posted: Wed Feb 29, 2012 4:09 pm Post subject: |
|
|
Где учишься то, что с массивами не справиться?) |
|
Back to top |
|
|
|
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
|