3v4l.org

run code in 300+ PHP versions simultaneously
<?php $tests = [ '133|mickmackusa|100|90|500', '133|mickmackusa|100|90', '133|mickmackusa|100', '133|mickmackusa', '133', '', ]; foreach ($tests as $test) { $matches = sscanf($test, '%d|%[^|]|%d|%d|%d', $user_id, $name, $limit, $remaining, $reset); var_export([ 'matches' => $matches, 'user_id' => $user_id, 'name' => $name, 'limit' => $limit, 'remaining' => $remaining, 'reset' => $reset ]); echo "\n"; unset($matches, $user_id, $name, $limit, $remaining, $reset); }
Output for 7.2.0, 8.0.1 - 8.0.30, 8.1.0 - 8.1.33, 8.2.0 - 8.2.29, 8.3.0 - 8.3.27, 8.4.1 - 8.4.14
array ( 'matches' => 5, 'user_id' => 133, 'name' => 'mickmackusa', 'limit' => 100, 'remaining' => 90, 'reset' => 500, ) array ( 'matches' => 4, 'user_id' => 133, 'name' => 'mickmackusa', 'limit' => 100, 'remaining' => 90, 'reset' => NULL, ) array ( 'matches' => 3, 'user_id' => 133, 'name' => 'mickmackusa', 'limit' => 100, 'remaining' => NULL, 'reset' => NULL, ) array ( 'matches' => 2, 'user_id' => 133, 'name' => 'mickmackusa', 'limit' => NULL, 'remaining' => NULL, 'reset' => NULL, ) array ( 'matches' => 1, 'user_id' => 133, 'name' => NULL, 'limit' => NULL, 'remaining' => NULL, 'reset' => NULL, ) array ( 'matches' => -1, 'user_id' => NULL, 'name' => NULL, 'limit' => NULL, 'remaining' => NULL, 'reset' => NULL, )

preferences:
103.99 ms | 409 KiB | 5 Q