There are two arrays, one contains unique values, and the second has many entries with identical headers - the name of the services and the cost. I want to add up all the amounts and withdraw the positions for the period in order to get the result:
- the ________ service was provided ___ times, for a total of ____ p.
Array of data to be calculated
$mv_today[] = array($s_name => array('vol' => $s_vol, 'price' => $u_price)); Data is stored as:
Body wash including thresholds: 1: 350 / Dry fog: 3: 700 /
Name: category: cost / ... It turns out I first pull everything out of the base, then on the fly form a report for the past day / month.
Array with unique values:
$uslugi[] = $s_name; Everything is simple - the name of the service, nothing more.
I somehow managed to make arrays myself, but I cannot connect them.
$result_today = mysql_query("SELECT * FROM history WHERE start_work BETWEEN '$start_date_today' AND '$stop_date_today' ORDER BY `history`.`start_work` DESC"); while ($row_today = mysql_fetch_array($result_today)){ $mv_today_all[] = $row_today[type]; //Π·Π°Π½ΠΎΡΠΈΠΌ Π²ΡΠ΅ Π·Π½Π°ΡΠ΅Π½ΠΈΡ Π² ΠΌΠ°ΡΡΠΈΠ² (Π³ΡΡΠ·Π½ΡΠΌΠΈ) };//while foreach ($mv_today_all as $key => $value) { $str_value = explode("/", $value); foreach($str_value as $str_val){ list($u_name, $u_cat, $u_price) = explode(":", $str_val); if ($u_name){ $s_vol = "1"; $s_name = $u_name."#".$u_cat; $mv_today[] = array($s_name => array('vol' => $s_vol, 'price' => $u_price)); $uslugi[] = $s_name; }//if ($u_name) }//foreach($str_value }//foreach ($mv_today_all $uslugi = array_unique($uslugi);