note 54826 deleted from function.trim by hholzgra
| From: | hholzgra@php.net | Date: | Thu, 02 Aug 2012 12:23:09 +0000 |
| Subject: | note 54826 deleted from function.trim by hholzgra | ||
| References: | 1 | Groups: | php.notes |
| Request: | Send a blank email to php-notes+get-189641@lists.php.net to get a copy of this message | ||
Note Submitter: rifter at cox dot net
----
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.