Then, once I have determined there are more than one dot, how can I remove all the dots but the right most one?



You can replace a limited number of matches using preg_replace(). <?php

$number = '123.456.789.10';
$count = substr_count($number, '.');
$number = preg_replace('/\./', '', $number, $count - 1);
echo $number;

?>

so 123.456.789.01 would become 123456789.01 with just the dot before the zero.

Thanks in advance.

-- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php



Reply via email to