3v4l.org

run code in 300+ PHP versions simultaneously
<?php $session = <<<TEXT # Session range - Number of visits BEGIN_SESSION 7 1h+ 10 5mn-15mn 9 0s-30s 107 2mn-5mn 7 30s-2mn 21 15mn-30mn 4 30mn-1h 11 END_SESSION TEXT; $newline = "\n"; $lines = explode($newline, $session); $results = []; foreach ($lines as $line) { if (sscanf($line, '%d%1s%s %d', $time, $unit, $tail, $count) === 4) { $times[] = $time; $units[] = $unit; $result[] = ["$time$unit$tail", $count]; } } array_multisort($units, $times, SORT_DESC, $result); var_export($result);
Output for 8.1.32, 8.2.0 - 8.2.29, 8.3.0 - 8.3.28, 8.4.1 - 8.4.14, 8.5.0 - 8.5.1
array ( 0 => array ( 0 => '1h+', 1 => 10, ), 1 => array ( 0 => '30mn-1h', 1 => 11, ), 2 => array ( 0 => '15mn-30mn', 1 => 4, ), 3 => array ( 0 => '5mn-15mn', 1 => 9, ), 4 => array ( 0 => '2mn-5mn', 1 => 7, ), 5 => array ( 0 => '30s-2mn', 1 => 21, ), 6 => array ( 0 => '0s-30s', 1 => 107, ), )
Output for 8.4.15
/bin/php-8.4.15: /usr/lib/libm.so.6: version `GLIBC_2.38' not found (required by /bin/php-8.4.15) /bin/php-8.4.15: /usr/lib/libm.so.6: version `GLIBC_2.35' not found (required by /bin/php-8.4.15) /bin/php-8.4.15: /usr/lib/libc.so.6: version `GLIBC_2.34' not found (required by /bin/php-8.4.15) /bin/php-8.4.15: /usr/lib/libc.so.6: version `GLIBC_2.38' not found (required by /bin/php-8.4.15)
Process exited with code 1.

preferences:
102 ms | 407 KiB | 5 Q