note 54826 added to function.trim
| From: | rifter at cox dot net | Date: | Sat, 16 Jul 2005 07:49:29 +0000 |
| Subject: | note 54826 added to function.trim | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-92052@lists.php.net to get a copy of this message | ||
Chris wrote:
> Here's a neat function to trim off extraneous zeros and the > decimal, leaving
> important numbers intact:
> ...
Actually use:
<?php
...
return rtrim(trim($num, '0'), '.');
...
?>
This ensures that a left leading decimal place doesn't get removed i.e. 00.010 should return
.01 and not 01.
----
Manual Page -- http://www.php.net/manual/en/function.trim.php
Edit -- http://master.php.net/manage/user-notes.php?action=edit+54826
Delete: added to the manual -- http://master.php.net/manage/user-notes.php?action=delete+54826&report=yes&reason=added+to+the+manual
Delete: bad code -- http://master.php.net/manage/user-notes.php?action=delete+54826&report=yes&reason=bad+code
Delete: spam -- http://master.php.net/manage/user-notes.php?action=delete+54826&report=yes&reason=spam
Delete: useless -- http://master.php.net/manage/user-notes.php?action=delete+54826&report=yes&reason=useless
Delete: non-english -- http://master.php.net/manage/user-notes.php?action=delete+54826&report=yes&reason=non-english
Delete: other reasons -- http://master.php.net/manage/user-notes.php?action=delete+54826&report=yes
Reject -- http://master.php.net/manage/user-notes.php?action=reject+54826&report=yes
Search -- http://master.php.net/manage/user-notes.php