3v4l.org

run code in 300+ PHP versions simultaneously
<?php $str = '1 2 3 4 5 6 7 8 9 Apollo-1 10'; if (preg_match_all('/(?<!\S)[-+]?\d*\.?\d+(?:[eE][-+]?\d+)?(?!\S)/', $str, $matches)) { print_r($matches[0]); }
Output for 7.1.25 - 7.1.31, 7.2.0 - 7.2.33, 7.3.0 - 7.3.28, 7.4.0 - 7.4.14, 8.0.0 - 8.0.3
Array ( [0] => 1 [1] => 2 [2] => 3 [3] => 4 [4] => 5 [5] => 6 [6] => 7 [7] => 8 [8] => 9 [9] => 10 )