I have a multidimensional array that looks like this..
$array = array (
'section1' => array (
'value' => 465,
'value2' => 744
),
'section2' => array (
'value' => 6544,
'value2' => 565
),
'section5' => array (
'value' => 345,
'value2' => 7465
)
);
I want to add all of the value2 together. I know I can do it with a for loop but is there a way to do it without doing this?
Could I use array_sum in combination with array_column to do this? The number of sections and the section name changes so I am not sure how to cater for this.
echo array_sum(array_column( $array, 'value2'));