note 27983 added to function.sprintf

From: Date: Sat, 28 Dec 2002 15:38:46 +0000
Subject: note 27983 added to function.sprintf
Groups: php.notes 
Request: Send a blank email to php-notes+get-41381@lists.php.net to get a copy of this message
Note that the oh-so-useful g and e formats are missing from PHP's sprintf(). If you want "no more than three decimals", your best bet is to do the job with string functions: $v = ereg_replace("\\.0+\$|(\\.[^0]+)0+\$", "\\1", sprintf("%.3f", (float)$v)); -- http://www.php.net/manual/en/function.sprintf.php http://master.php.net/manage/user-notes.php?action=edit+27983 http://master.php.net/manage/user-notes.php?action=delete+27983 http://master.php.net/manage/user-notes.php?action=reject+27983

« previous php.notes (#41381) next »