note 84590 modified in function.floatval by danbrown

From: Date: Mon, 21 Jul 2008 03:53:09 +0000
Subject: note 84590 modified in function.floatval by danbrown
References: 1  Groups: php.notes 
Request: Send a blank email to php-notes+get-142402@lists.php.net to get a copy of this message
Most of the functions listed here that deal with $ and , are unnecessarily complicated. You can use ereg_replace() to strip out ALL of the characters that will cause floatval to fail in one simple line of code: <?php $output = floatval(ereg_replace("[^-0-9\.]","",$input)); ?> --was-- Most of the functions listed here that deal with $ and , are unnecessarily complicated. You can use ereg_replace() to strip out ALL of the characters that will cause floatval to fail in one simple line of code: <? $output = floatval(ereg_replace("[^-0-9\.]","",$input)); ?> http://php.net/manual/en/function.floatval.php

« previous php.notes (#142402) next »