3v4l.org

run code in 300+ PHP versions simultaneously
<?php $sql = array( array( 'date_max' => '2019-12-15', 'id_property' => 18, 'last_validation' => 1 ), array( 'date_max' => '2020-08-31', 'id_property' => 18, 'last_validation' => 5 ), array( 'date_max' => '2019-12-15', 'id_property' => 21, 'last_validation' => 1 ) ); $data = []; //create array of results grouped by the property id foreach($sql as $current_key => $current_array) { $ts = strtotime($current_array['date_max']); //unix timestamp from date $data[$current_array['id_property']][$ts] = $current_array; } $maxData = []; foreach($data as $propertId=>$values) { ksort($values); //sort by key, highest value first $maxData[] = array_pop($values); //take first value } print_r($maxData);
Output for git.master, git.master_jit, rfc.property-hooks
Array ( [0] => Array ( [date_max] => 2020-08-31 [id_property] => 18 [last_validation] => 5 ) [1] => Array ( [date_max] => 2019-12-15 [id_property] => 21 [last_validation] => 1 ) )

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:
41.69 ms | 1433 KiB | 4 Q