There are a few ways to handle it, but a simple modification to your existing code would be to return
values from your array_map()
and sum the resultant array with array_sum()
.
$toPluck = 'price';
$arr = $gamesWorth;
$plucked = array_map(function($item) use($toPluck) {
// Uncomment this if you want to print individual values
// Otherwise the array_map() produces no output to the screen
// echo $item[$toPluck];
// And return the value you need
return $item[$toPluck];
}, $arr);
// $plucked is now an array
echo array_sum($plucked);