I want to get the (first) price of each string row, with out the $ sign and it could be an int or float and there could be more numbers in the row.
example:
$str_array=(
"Up to $1.9 per Install in RU",
"1.3 per iOS Install in UAE and SA",
"$2.1 per iOS and Android Registration in US",
"Up to $2.5 per Android Install in 7 countries",
"Up to $1 per iOS Install in SA"
);
Expected output:
1.9
1.3
2.1
2.5
1
I tried something like this
$re = '/[+-]?([0-9]*[.])?[0-9]+/';
$str = 'Up to $2.5 per Android Install in 7 countries';
preg_match_all($re, $str, $matches, PREG_SET_ORDER, 0);
var_dump($matches);
and i get this
[0] => Array
(
[0] => 2.5
[1] => 2.
)
[1] => Array
(
[0] => 7
)
but its not working good. :(