- preg_match: documentation ( source)
- print_r: documentation ( source)
<?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));