Advertisement
Guest User

Untitled

a guest
Oct 1st, 2016
55
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.69 KB | None | 0 0
  1. $buyList = array(
  2. array('name' => 'Телевизор', 'price' => '400', 'quantity' => 1),
  3. array('name' => 'Телефон', 'price' => '300', 'quantity' => 3),
  4. array('name' => 'Кросовки', 'price' => '150', 'quantity' => 2),
  5. );
  6.  
  7. function resultBuyList($buyList)
  8. {
  9. foreach ($buyList  as $key => $value) {
  10. $credits = $value['quantity'] * $value['price'];
  11. $creditCount += $credits;
  12. $productCount += $value['quantity'];
  13. }
  14. return $result = "Вы купили $productCount единиц товара, общая сумма к оплате: $creditCount";
  15. }
  16.  
  17.  
  18. resultBuyList($buyList);
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement