sum of multidimensional array in php

Solutions on MaxInterview for sum of multidimensional array in php by the best coders in the world

showing results for - "sum of multidimensional array in php"
Máximo
08 Aug 2020
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
Frieda
23 Nov 2017
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?>
queries leading to this page
multiple array elements sum phpphp sum of 2 arraysum all vlaues in multi dimentional array phpsum value in multidimensional array phparray sum php multidimensional conditionalsum multiple arrays phparray sum in multidimensional array phphow to sum multiple array values in phpphp sum multidimensional array valuestwo array sum in phpphp sum 2 dimensional arrayphp array sum multidimensionalphp sum array multidimensionsphp sum a column in a multidimensional arraymultidimensional array sum in phpsum multiple array php2d array sum phpsum two value in multidimensional array phpphp sum values of multidimensional array by two keyssum of multiple arrays phpphp sum array multidimensionaladd to multidimensional array phphow to sum values of multidimensional array in phpsum multiple array in phpget sum of array element php 2d arraysum multiple array values phparray sum php multidimensionalsum specific values in a multidimensional array 28php 29sum of two matrix phpnested array sum and number phpphp sum 3 dimensional arrayphp multidimension array add all valuesphp sum multidimensional arrayget sum array from two array in phpphp sum multidimensional array key valuearray sum in multidimensional array in phpphp multidimensional array sum by keyarray sum multidimensional php classphp total sum in multidimensional arrayphp multidimensional array with string and number to find totalsum of elements in multidimensional array phpsum multidimensional array phpsum of multidimensional array in phparray sum multidimensional phpsum of multidimensional array in php