3v4l.org

run code in 300+ PHP versions simultaneously
<?php $saved_royalties = [ [ 'gross_total' => 1.797, 'track_name' => 'Desert Dance', 'transaction_type' => 'S' ], [ 'gross_total' => 0.0678, 'track_name' => 'Memphis City Of Kings', 'transaction_type' => 'AS' ], [ 'gross_total' => 0.023, 'track_name' => 'North African Market', 'transaction_type' => 'MT' ], [ 'gross_total' => 0.1173, 'track_name' => 'The Oracle', 'transaction_type' => 'CL' ] ]; $matching_royalty_rows = [ [ 'gross_total' => 2.435174, 'track_name' => 'Desert Dance', 'transaction_type' => 'S' ], [ 'gross_total' => 0.336815, 'track_name' => 'Memphis City Of Kings', 'transaction_type' => 'AS' ], [ 'gross_total' => 0.214106, 'track_name' => 'The Oracle', 'transaction_type' => 'CL' ] ]; $lookup = array_column($matching_royalty_rows, null, 'track_name'); $combined_rows = []; foreach ($saved_royalties as $row) { if (isset($lookup[$row['track_name']])) { $row = $lookup[$row['track_name']]; } else { $row['gross_total'] = 0; } $combined_rows[] = $row; } var_export($combined_rows);
Output for git.master, git.master_jit, rfc.property-hooks
array ( 0 => array ( 'gross_total' => 2.435174, 'track_name' => 'Desert Dance', 'transaction_type' => 'S', ), 1 => array ( 'gross_total' => 0.336815, 'track_name' => 'Memphis City Of Kings', 'transaction_type' => 'AS', ), 2 => array ( 'gross_total' => 0, 'track_name' => 'North African Market', 'transaction_type' => 'MT', ), 3 => array ( 'gross_total' => 0.214106, 'track_name' => 'The Oracle', 'transaction_type' => 'CL', ), )

This tab shows result from various feature-branches currently under review by the php developers. Contact me to have additional branches featured.

Active branches

Archived branches

Once feature-branches are merged or declined, they are no longer available. Their functionality (when merged) can be viewed from the main output page


preferences:
122.64 ms | 407 KiB | 5 Q