1<?php
2$items = [
3 ['label' => 'cake', 'name' => 'Cake', 'price' => 150],
4 ['label' => 'pizza', 'name' => 'Pizza', 'price' => 250],
5 ['label' => 'puff', 'name' => 'Veg Puff', 'price' => 20],
6 ['label' => 'samosa', 'name' => 'Samosa', 'price' => 14]
7];
8
9$arrSum = array_sum(array_column($items, 'price', 'name'));
10print "Sum of Array : ".$arrSum."<br/>";
11?>
12
1<?php
2
3$items = [
4 ['label' => 'cake', 'name' => 'Cake', 'price' => 150],
5 ['label' => 'pizza', 'name' => 'Pizza', 'price' => 250],
6 ['label' => 'puff', 'name' => 'Veg Puff', 'price' => 20],
7 ['label' => 'samosa', 'name' => 'Samosa', 'price' => 14]
8];
9
10$arrSum = array_sum(array_column($items, 'price', 'name'));
11print "Sum of Array : ".$arrSum."<br/>";
12?>