I have an unknwon string that could resemble a float. In that case I want to convert it to float (for calculations), otherwise leave it as a string.
maybe you would like to use the non-locale-aware floatval function:
float floatval ( mixed $var ) - Gets the float value of a string.
float floatval ( mixed $var )
Example from the documentation:
$string = '122.34343The'; $float = floatval($string); echo $float; // 122.34343