3v4l.org

run code in 300+ PHP versions simultaneously
<?php function get_numerics ($str) { $matches = array(); $pattern = '/(?:$|[$])\s*\d+(?:\.\d{2})?/'; if (preg_match($pattern, $string, $matches)) { return $matches[0]; } } $one = 'Producto de prueba 16gb \n $100 - Buenos Aires, Argentina\n \n Algun texto de un producto'; print_r(get_numerics($one));

preferences:
61.18 ms | 402 KiB | 5 Q