note 97762 added to function.ltrim
| From: | tanmar dot de at osu1 dot php dot net | Date: | Thu, 06 May 2010 17:36:20 +0000 |
| Subject: | note 97762 added to function.ltrim | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-169028@lists.php.net to get a copy of this message | ||
The neat trick from Mr. Sherwood has only one ugly side-effect: If the "number" contained
in the string is considerably large, you will end up with an int (or float) value that has nothing
to do with the original number ...
You may use preg_replace instead:
$number_string = preg_replace('~^[0]*([1-9][0-9]*)$~','$1',$number_string);
This kills any leading zeros safely without changing any other data.
Hope this helps.
----
Server IP: 69.147.83.197
Probable Submitter: 95.88.18.147
----
Manual Page -- http://www.php.net/manual/en/function.ltrim.php
Edit -- https://master.php.net/note/edit/97762
Del: integrated -- https://master.php.net/note/delete/97762/integrated
Del: useless -- https://master.php.net/note/delete/97762/useless
Del: bad code -- https://master.php.net/note/delete/97762/bad+code
Del: spam -- https://master.php.net/note/delete/97762/spam
Del: non-english -- https://master.php.net/note/delete/97762/non-english
Del: in docs -- https://master.php.net/note/delete/97762/in+docs
Del: other reasons-- https://master.php.net/note/delete/97762
Reject -- https://master.php.net/note/reject/97762
Search -- https://master.php.net/manage/user-notes.php