<?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);
preferences:
24.08 ms | 405 KiB | 5 Q