note 105084 deleted from function.sprintf by danbrown

From: Date: Tue, 26 Jul 2011 21:42:08 +0000
Subject: note 105084 deleted from function.sprintf by danbrown
References: 1  Groups: php.notes 
Request: Send a blank email to php-notes+get-181922@lists.php.net to get a copy of this message
Note Submitter: Nick Carenza ---- 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!

« previous php.notes (#181922) next »