note 105084 added to function.sprintf
| From: | NickCarenza at osu1 dot php dot net | Date: | Tue, 26 Jul 2011 20:58:56 +0000 |
| Subject: | note 105084 added to function.sprintf | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-181921@lists.php.net to get a copy of this message | ||
Sprintf and Phone Numbers:
PHPs integer limit is 2147483647 and this applies to sprintf's %d.
For example:
$phone='18004235233';
sprintf('%d',$phone);
will return 2147483647 because the expected result of 18002345233 is greater than the integer
maximum.
Also, sprintf won't parse your phone number and take out all no digits with %d.
For example:
$phone='1-800-423-5233';
sprintf('%d',$phone);
will return 1.
Instead you can do:
$phone=preg_replace('/\D/', '', '1-800-234-5233');
sprintf('%s',$phone);
Good luck!
----
Server IP: 69.147.83.197
Probable Submitter: 12.222.191.27
----
Manual Page -- http://www.php.net/manual/en/function.sprintf.php
Edit -- https://master.php.net/note/edit/105084
Del: integrated -- https://master.php.net/note/delete/105084/integrated
Del: useless -- https://master.php.net/note/delete/105084/useless
Del: bad code -- https://master.php.net/note/delete/105084/bad+code
Del: spam -- https://master.php.net/note/delete/105084/spam
Del: non-english -- https://master.php.net/note/delete/105084/non-english
Del: in docs -- https://master.php.net/note/delete/105084/in+docs
Del: other reasons-- https://master.php.net/note/delete/105084
Reject -- https://master.php.net/note/reject/105084
Search -- https://master.php.net/manage/user-notes.php