note 31892 added to function.sprintf

From: Date: Thu, 08 May 2003 07:55:18 +0000
Subject: note 31892 added to function.sprintf
Groups: php.notes 
Request: Send a blank email to php-notes+get-47673@lists.php.net to get a copy of this message
If you want to cut all the zeros off the end of a float, but not losing any sensitive information, use this: <? function cutzero($value) { return preg_replace("/(\.\d+?)0+$/", "$1", $value)*1; } ?> Some examples: <? cutzero("4.7600"); // returns 4.76 cutzero("4.7604") // returns 4.7604 cutzero("4.7000"); // returns 4.7 cutzero("4.0000"); // returns 4 ?> -- http://www.php.net/manual/en/function.sprintf.php http://master.php.net/manage/user-notes.php?action=edit+31892 http://master.php.net/manage/user-notes.php?action=delete+31892 http://master.php.net/manage/user-notes.php?action=reject+31892

« previous php.notes (#47673) next »