3v4l.org

run code in 150+ php & hhvm versions
Bugs & Features
<?php $array = array( array('apn' => 345345345, 'sqft' => 1200, 'address' => '323 Pacific Ave.'), array('apn' => 345345342, 'sqft' => 1421, 'address' => '324 Pacific Ave.'), array('apn' => 345345346, 'sqft' => 1012, 'address' => '325 Pacific Ave.'), array('apn' => 345345347, 'sqft' => 1093, 'address' => '328 Pacific Ave.'), array('apn' => 345345353, 'sqft' => 1121, 'address' => '12 Lincoln Ave.'), array('apn' => 345345351, 'sqft' => 1643, 'address' => '13 Lincoln Ave.'), array('apn' => 345345352, 'sqft' => 1222, 'address' => '14 Lincoln Ave.') ); usort($array, function($x, $y) { $x = preg_split('/^(\d+)\s+(.*)/', $x['address'], -1 , 3); $y = preg_split('/^(\d+)\s+(.*)/', $y['address'], -1 , 3); $x[2] = $x[0] % 2; $y[2] = $y[0] % 2; if($x[1]==$y[1]) { if($x[2]==$y[2]) return $x[0]<$y[0]?-1:$x[0]!=$y[0]; return $x[2]>$y[2]?-1:1; } return $x[1]<$y[1]?-1:1; }); var_dump($array);
Output for 5.3.7 - 5.6.28, hhvm-3.12.0, 7.0.0 - 7.1.0
array(7) { [0]=> array(3) { ["apn"]=> int(345345351) ["sqft"]=> int(1643) ["address"]=> string(15) "13 Lincoln Ave." } [1]=> array(3) { ["apn"]=> int(345345353) ["sqft"]=> int(1121) ["address"]=> string(15) "12 Lincoln Ave." } [2]=> array(3) { ["apn"]=> int(345345352) ["sqft"]=> int(1222) ["address"]=> string(15) "14 Lincoln Ave." } [3]=> array(3) { ["apn"]=> int(345345345) ["sqft"]=> int(1200) ["address"]=> string(16) "323 Pacific Ave." } [4]=> array(3) { ["apn"]=> int(345345346) ["sqft"]=> int(1012) ["address"]=> string(16) "325 Pacific Ave." } [5]=> array(3) { ["apn"]=> int(345345342) ["sqft"]=> int(1421) ["address"]=> string(16) "324 Pacific Ave." } [6]=> array(3) { ["apn"]=> int(345345347) ["sqft"]=> int(1093) ["address"]=> string(16) "328 Pacific Ave." } }
Output for hhvm-3.10.0

Process exited with code 153.