3v4l.org

run code in 300+ PHP versions simultaneously
<?php $unresponsives4 = $unresponsives3 = $unresponsives2 = $unresponsives = [ [ "Customer", "172.52.46.75", "2022-04-01 16:20:45", "1817", "nxlog", "2328.02 Hours" ], [ "Customer", "172.25.89.45", "2022-04-01 16:20:45", "1817", "nxlog", "Undefined" ], [ "Customer", "172.19.10.94", "2022-04-01 16:20:45", "1817", "nxlog", "2324.02 Hours" ], [ "Customer", "172.19.10.94", "2022-04-01 16:20:45", "1817", "nxlog", "2322.02 Hours" ], [ "Customer", "172.19.10.94", "2022-04-01 16:20:45", "1817", "nxlog", "Undefined" ], ]; function compd1($a, $b) { $v1 = $a[5]; $v2 = $b[5]; if ('Undefined' === $v1) { $v1 = PHP_INT_MAX; } if ('Undefined' === $v2) { $v2 = PHP_INT_MAX; } return floatval($v2) <=> floatval($v1); } usort($unresponsives, 'compd1'); var_export($unresponsives); echo PHP_EOL . PHP_EOL; function compd2($a, $b) { return ('Undefined' === $b[5] ? PHP_INT_MAX : floatval($b[5])) <=> ('Undefined' === $a[5] ? PHP_INT_MAX : floatval($a[5])); } usort($unresponsives2, 'compd2'); var_export($unresponsives2); echo PHP_EOL . PHP_EOL; echo '---------------------------------------------------------------'; echo PHP_EOL . PHP_EOL; function compa1($a, $b) { $v1 = $a[5]; $v2 = $b[5]; if ('Undefined' === $v1) { $v1 = PHP_INT_MIN; } if ('Undefined' === $v2) { $v2 = PHP_INT_MIN; } return floatval($v1) <=> floatval($v2); } usort($unresponsives3, 'compa1'); var_export($unresponsives3); echo PHP_EOL . PHP_EOL; function compa2($a, $b) { return ('Undefined' === $a[5] ? PHP_INT_MIN : floatval($a[5])) <=> ('Undefined' === $b[5] ? PHP_INT_MIN : floatval($b[5])); } usort($unresponsives4, 'compa2'); var_export($unresponsives4);
Output for 7.4.0 - 7.4.33, 8.0.1 - 8.0.30, 8.1.0 - 8.1.28, 8.2.0 - 8.2.19, 8.3.0 - 8.3.7
array ( 0 => array ( 0 => 'Customer', 1 => '172.25.89.45', 2 => '2022-04-01 16:20:45', 3 => '1817', 4 => 'nxlog', 5 => 'Undefined', ), 1 => array ( 0 => 'Customer', 1 => '172.19.10.94', 2 => '2022-04-01 16:20:45', 3 => '1817', 4 => 'nxlog', 5 => 'Undefined', ), 2 => array ( 0 => 'Customer', 1 => '172.52.46.75', 2 => '2022-04-01 16:20:45', 3 => '1817', 4 => 'nxlog', 5 => '2328.02 Hours', ), 3 => array ( 0 => 'Customer', 1 => '172.19.10.94', 2 => '2022-04-01 16:20:45', 3 => '1817', 4 => 'nxlog', 5 => '2324.02 Hours', ), 4 => array ( 0 => 'Customer', 1 => '172.19.10.94', 2 => '2022-04-01 16:20:45', 3 => '1817', 4 => 'nxlog', 5 => '2322.02 Hours', ), ) array ( 0 => array ( 0 => 'Customer', 1 => '172.25.89.45', 2 => '2022-04-01 16:20:45', 3 => '1817', 4 => 'nxlog', 5 => 'Undefined', ), 1 => array ( 0 => 'Customer', 1 => '172.19.10.94', 2 => '2022-04-01 16:20:45', 3 => '1817', 4 => 'nxlog', 5 => 'Undefined', ), 2 => array ( 0 => 'Customer', 1 => '172.52.46.75', 2 => '2022-04-01 16:20:45', 3 => '1817', 4 => 'nxlog', 5 => '2328.02 Hours', ), 3 => array ( 0 => 'Customer', 1 => '172.19.10.94', 2 => '2022-04-01 16:20:45', 3 => '1817', 4 => 'nxlog', 5 => '2324.02 Hours', ), 4 => array ( 0 => 'Customer', 1 => '172.19.10.94', 2 => '2022-04-01 16:20:45', 3 => '1817', 4 => 'nxlog', 5 => '2322.02 Hours', ), ) --------------------------------------------------------------- array ( 0 => array ( 0 => 'Customer', 1 => '172.25.89.45', 2 => '2022-04-01 16:20:45', 3 => '1817', 4 => 'nxlog', 5 => 'Undefined', ), 1 => array ( 0 => 'Customer', 1 => '172.19.10.94', 2 => '2022-04-01 16:20:45', 3 => '1817', 4 => 'nxlog', 5 => 'Undefined', ), 2 => array ( 0 => 'Customer', 1 => '172.19.10.94', 2 => '2022-04-01 16:20:45', 3 => '1817', 4 => 'nxlog', 5 => '2322.02 Hours', ), 3 => array ( 0 => 'Customer', 1 => '172.19.10.94', 2 => '2022-04-01 16:20:45', 3 => '1817', 4 => 'nxlog', 5 => '2324.02 Hours', ), 4 => array ( 0 => 'Customer', 1 => '172.52.46.75', 2 => '2022-04-01 16:20:45', 3 => '1817', 4 => 'nxlog', 5 => '2328.02 Hours', ), ) array ( 0 => array ( 0 => 'Customer', 1 => '172.25.89.45', 2 => '2022-04-01 16:20:45', 3 => '1817', 4 => 'nxlog', 5 => 'Undefined', ), 1 => array ( 0 => 'Customer', 1 => '172.19.10.94', 2 => '2022-04-01 16:20:45', 3 => '1817', 4 => 'nxlog', 5 => 'Undefined', ), 2 => array ( 0 => 'Customer', 1 => '172.19.10.94', 2 => '2022-04-01 16:20:45', 3 => '1817', 4 => 'nxlog', 5 => '2322.02 Hours', ), 3 => array ( 0 => 'Customer', 1 => '172.19.10.94', 2 => '2022-04-01 16:20:45', 3 => '1817', 4 => 'nxlog', 5 => '2324.02 Hours', ), 4 => array ( 0 => 'Customer', 1 => '172.52.46.75', 2 => '2022-04-01 16:20:45', 3 => '1817', 4 => 'nxlog', 5 => '2328.02 Hours', ), )

preferences:
148.26 ms | 410 KiB | 123 Q