3v4l.org

run code in 300+ PHP versions simultaneously
<?php $arr = array ( 0 => array ( 'vehicle' => 'BUS NO.1', 'trip_name' => 'Trip00011', 'running_km' => '5000', ), 1 => array ( 'vehicle' => 'BUS NO.2', 'trip_name' => 'Trip00021', 'running_km' => '2400', ), 2 => array ( 'vehicle' => 'BUS NO.1', 'trip_name' => 'Trip00011', 'running_km' => '0', ), 3 => array ( 'vehicle' => 'BUS NO.2', 'trip_name' => 'Trip00011', 'running_km' => '0', ), 4 => array ( 'vehicle' => 'BUS NO.2', 'trip_name' => 'Trip00021', 'running_km' => '0', ), ); foreach($arr as $item){ $key = $item['vehicle'] . $item['trip_name']; if(isset($new[$key])){ if($item['running_km'] > $new[$key]['running_km']) $new[$key] = $item; }else{ $new[$key] = $item; } } $new = array_values($new); Var_dump($new);
Output for git.master, git.master_jit, rfc.property-hooks
array(3) { [0]=> array(3) { ["vehicle"]=> string(8) "BUS NO.1" ["trip_name"]=> string(9) "Trip00011" ["running_km"]=> string(4) "5000" } [1]=> array(3) { ["vehicle"]=> string(8) "BUS NO.2" ["trip_name"]=> string(9) "Trip00021" ["running_km"]=> string(4) "2400" } [2]=> array(3) { ["vehicle"]=> string(8) "BUS NO.2" ["trip_name"]=> string(9) "Trip00011" ["running_km"]=> string(1) "0" } }

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