3v4l.org

run code in 200+ php & hhvm versions
Bugs & Features
<?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));
based on olGrv
Output for 5.6.0 - 5.6.30, 7.0.0 - 7.3.0beta1
Notice: Undefined variable: string in /in/tFreK on line 6
Output for hhvm-3.12.14 - 3.17.3
Notice: Undefined variable: string in /in/tFreK on line 6 Warning: preg_match() expects parameter 2 to be string, null given in /in/tFreK on line 6