Witaj Gościu! ( Zaloguj | Rejestruj )

Forum PHP.pl

> [PHP] suma jeżeli
dentopolis
post 4.09.2016, 16:30:25
Post #1





Grupa: Zarejestrowani
Postów: 252
Pomógł: 0
Dołączył: 14.08.2016

Ostrzeżenie: (0%)
-----


mam zmienne:
$rightloweroneyoung = $row['81'];
$rightlowertwoyoung = $row['82'];
$rightlowerthreeyoung = $row['83'];
$rightlowerfouryoung = $row['84'];
$rightlowerfiveyoung = $row['85'];

wartości $row...zawierają litery: c lub w lub x.

jak liczyć sumę "c"?
Go to the top of the page
+Quote Post
 
Start new topic
Odpowiedzi (1 - 1)
trueblue
post 4.09.2016, 16:38:41
Post #2





Grupa: Zarejestrowani
Postów: 6 804
Pomógł: 1827
Dołączył: 11.03.2014

Ostrzeżenie: (0%)
-----


  1. function sumifx($v,$w){
  2. return $v+=$w=='x';
  3. }
  4. $a=array('x','a','x','x','b');
  5. $b=array_reduce($a, "sumifx");
  6. echo $b;


Zmień 'x' na 'c'.

Ten post edytował trueblue 4.09.2016, 16:39:19


--------------------
Go to the top of the page
+Quote Post

Reply to this topicStart new topic
1 Użytkowników czyta ten temat (1 Gości i 0 Anonimowych użytkowników)
0 Zarejestrowanych:

 



RSS Wersja Lo-Fi Aktualny czas: 29.06.2025 - 13:01