3v4l.org

run code in 300+ PHP versions simultaneously
<?php $season_data = [ 'Paul' => [ 'Season' => [2014, 2015, 2016] ], 'John' => [ 'Season' => [2012] ] ]; $appearance_data = [ 'Paul' => [ 'Appearance'=> [ 2014, 2014, 2014, 2014, 2014, 2014, 2014, 2014, 2015, 2015, 2015 ] ], 'John' => [ 'Appearance' => [ 2012, 2012, 2012, 2012 ] ] ]; foreach ($season_data as $person => $data) { $defaults = array_fill_keys($data['Season'], 0); $result[$person]['SeasonCounts'] = array_replace( $defaults, array_intersect_key( array_count_values($appearance_data[$person]['Appearance']), $defaults ) ); } var_export($result);
Output for git.master, git.master_jit, rfc.property-hooks
array ( 'Paul' => array ( 'SeasonCounts' => array ( 2014 => 8, 2015 => 3, 2016 => 0, ), ), 'John' => array ( 'SeasonCounts' => array ( 2012 => 4, ), ), )

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:
120.7 ms | 406 KiB | 5 Q