3v4l.org

run code in 300+ PHP versions simultaneously
<?php $array = [ [ 'price' => [ 'cost' => 200, 'tax' => 10, 'total' => 210 ], 'otherKey' => 'etc' ], [ 'price' => [ 'cost' => 500, 'tax' => 50, 'total' => 550 ], 'otherKey' => 'etc' ], [ 'price' => [ 'cost' => 600, 'tax' => 60, 'total' => 660 ], 'otherKey' => 'etc' ], ]; $totals = []; array_walk_recursive( $array, function($leafNode, $key) use(&$totals) { if ($key === 'total') { $totals[] = $leafNode; } } ); var_export($totals);

preferences:
36.58 ms | 405 KiB | 5 Q