I got a string like:
$str = \"CASH55.35inMyPocket\";
I want to get 55.35 only.
I tried:
$str = flo
Modifying @hek2mgl answer to get both float and integer numbers
preg_match('/([0-9]+\.?[0-9].)/', 'CASH55.35inMyPocket', $matches);
$number = (float) $matches[1]; // 55.35
preg_match('/([0-9]+\.?[0-9].)/', 'CASH55inMyPocket', $matches);
$number = (float) $matches[1]; // 55
preg_match('/([0-9]+\.?[0-9].)/', 'Total.CASH55.35inMyPocket', $matches); //with a dot before number
$number = (float) $matches[1]; // 55.35