array column sum php code example
Example 1: array_column in php
$a = array(
array(
'id' => 5698,
'first_name' => 'Peter',
'last_name' => 'Griffin',
),
array(
'id' => 4767,
'first_name' => 'Ben',
'last_name' => 'Smith',
),
array(
'id' => 3809,
'first_name' => 'Joe',
'last_name' => 'Doe',
)
);
$last_names = array_column($a, 'last_name');
print_r($last_names);
Example 2: php sum array elements
<?php
$a=array(5,15,25);
echo array_sum($a);
?>