I'd like to extract percentages from a string in php but I got a problem if number has not decimal.
Actually, I use this:
$string = "This is a text with value 10.1%"
preg_match("/[0-9]+\.[0-9]+%/", $string, $matches);
In this example all works great cause I can extract: 10.1%
But with this string:
$string = "This is a text with value 10%"
...nothing returned.
I'd like to extract 10% or 10.1% (with decimals) with same code. Any help will be appreciated.