Array ( [6254] => Array ( [check] => on [quantity] => 2 [name] => Testing product_special One Size [total] => 66.0000 [price] => 33.0000 ) [6255] => Array ( [check] => on [quantity] => 1 [name] => Testing card [total] => 80.85 [price] => 33.0000 ) )
Above is my array .
My Code
foreach($value as $key2 => $value2){
$name = preg_replace('/\s+/', '', $key);
echo "<pre>";
// print_r(array_sum(array_column($value, 'price')));
print_r($value);
echo "</pre>";
exit;
}
wanted to ask , how do i "specifically" add prices ? tried with
$totalprice += $value['price'];
is not working
array_sum(array_column($value, 'price')) < this code fixed my problem
but there is a new question , what if need to check on "condition"
if "check" = on only able to sum , if there is no "check" ignore the array
key
are you referring to? – Kevinarray_sum(array_column($value, 'price'))
should be working for you. – ROOT