Answer the question
In order to leave comments, you need to log in
Error: Unable to execute code, syntax contains errors! Where is the question? In which place?
Hello! Everyone's favorite tasks on arrays ...
The question is where did I make a mistake in the code? The problem was solved in two ways with the help of Google naturally ...
$basket = [
[
'position' => "Книга по php",
'quantity' => 1,
],
[
'position' => "Мышь беспроводная",
'quantity' => 12,
]
];
countBasket($basket);
function countBasket($all)
{
$sum = 0;
foreach ($all as ['quantity' => $quantity]) {
$sum += $quantity;
}
echo $sum;
return $sum;
}
$basket = [
[
'position' => "Книга по php",
'quantity' => 1,
],
[
'position' => "Мышь беспроводная",
'quantity' => 12,
]
];
function countBasket($all)
{
$sum = 0;
foreach ($all as ['quantity' => $quantity]) {
$sum += $quantity;
}
echo $sum;
return $sum;
}
countBasket($basket);
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