3v4l.org

run code in 200+ php & hhvm versions
Bugs & Features
<?php $ar = Array ( 0 => Array ( 'name' => "The 5th Wave", 'releaseDate' => '2016-01-22', 'dates' => Array ( 'date' => Array ( 0 => '2016-01-27', 1 => '2016-01-26' ) ) ), 1 => Array ( 'name' => 'Dirty Grandpa', 'releaseDate' => '2016-01-21', 'dates' => Array ( 'date' => Array ( 0 => '2016-01-27', 1 => '2016-01-26' ) ) ), 2 => Array ( 'name' => 'The Revenant', 'releaseDate' => '2016-01-14', 'dates' => Array ( 'date' => Array ( 0 => '2016-01-27', 1 => '2016-01-26' ) ) ) ); print_r($ar); echo "================Sort============="; uasort($ar, function($a, $b){ if( end($array['dates']['date']) < $array['releaseDate'] OR end($a['dates']['date']) > date("Y-m-d", strtotime('next thursday')) ){ return -1; } else{ return 0; } }); print_r($ar);
based on WcbXT
Output for 7.0.0 - 7.2.0
Array ( [0] => Array ( [name] => The 5th Wave [releaseDate] => 2016-01-22 [dates] => Array ( [date] => Array ( [0] => 2016-01-27 [1] => 2016-01-26 ) ) ) [1] => Array ( [name] => Dirty Grandpa [releaseDate] => 2016-01-21 [dates] => Array ( [date] => Array ( [0] => 2016-01-27 [1] => 2016-01-26 ) ) ) [2] => Array ( [name] => The Revenant [releaseDate] => 2016-01-14 [dates] => Array ( [date] => Array ( [0] => 2016-01-27 [1] => 2016-01-26 ) ) ) ) ================Sort============= Warning: end() expects parameter 1 to be array, null given in /in/hAerl on line 55 Notice: Undefined index: releaseDate in /in/hAerl on line 55 Warning: end() expects parameter 1 to be array, null given in /in/hAerl on line 55 Notice: Undefined index: releaseDate in /in/hAerl on line 55 Array ( [0] => Array ( [name] => The 5th Wave [releaseDate] => 2016-01-22 [dates] => Array ( [date] => Array ( [0] => 2016-01-27 [1] => 2016-01-26 ) ) ) [1] => Array ( [name] => Dirty Grandpa [releaseDate] => 2016-01-21 [dates] => Array ( [date] => Array ( [0] => 2016-01-27 [1] => 2016-01-26 ) ) ) [2] => Array ( [name] => The Revenant [releaseDate] => 2016-01-14 [dates] => Array ( [date] => Array ( [0] => 2016-01-27 [1] => 2016-01-26 ) ) ) )
Output for 5.5.0 - 5.6.28
Array ( [0] => Array ( [name] => The 5th Wave [releaseDate] => 2016-01-22 [dates] => Array ( [date] => Array ( [0] => 2016-01-27 [1] => 2016-01-26 ) ) ) [1] => Array ( [name] => Dirty Grandpa [releaseDate] => 2016-01-21 [dates] => Array ( [date] => Array ( [0] => 2016-01-27 [1] => 2016-01-26 ) ) ) [2] => Array ( [name] => The Revenant [releaseDate] => 2016-01-14 [dates] => Array ( [date] => Array ( [0] => 2016-01-27 [1] => 2016-01-26 ) ) ) ) ================Sort============= Warning: end() expects parameter 1 to be array, null given in /in/hAerl on line 55 Notice: Undefined index: releaseDate in /in/hAerl on line 55 Warning: end() expects parameter 1 to be array, null given in /in/hAerl on line 55 Notice: Undefined index: releaseDate in /in/hAerl on line 55 Array ( [2] => Array ( [name] => The Revenant [releaseDate] => 2016-01-14 [dates] => Array ( [date] => Array ( [0] => 2016-01-27 [1] => 2016-01-26 ) ) ) [1] => Array ( [name] => Dirty Grandpa [releaseDate] => 2016-01-21 [dates] => Array ( [date] => Array ( [0] => 2016-01-27 [1] => 2016-01-26 ) ) ) [0] => Array ( [name] => The 5th Wave [releaseDate] => 2016-01-22 [dates] => Array ( [date] => Array ( [0] => 2016-01-27 [1] => 2016-01-26 ) ) ) )