Answer the question
In order to leave comments, you need to log in
Calculate the sum of elements in a quantity field / PHP?
You need to create a function called countBasket, with one parameter - an array of positions in the basket.
The function should calculate and return how many items are in the cart (there can be several items in one item of the cart - the quantity field).
An array of the following structure will be passed to your function:
$basket = [
[
'position' => 'Book',
'quantity' => 1,
],
[
'position' => 'Mouse',
'quantity' => 12,
],
]
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question