Format.php – v1.0

format-v1-0.zip – v1.0
release: 2/24/2009
md5: 8de8157e010d81159e650441d480033c
View typical usage examples
Format.php is a class used statically to formation information to and from the user. Right now the class is fairly US based because that is where most of my applications are from. If you would like to help update some of the functions to have better international support please let me know.
Here are some of the functions that Format.php provides:
Phone Number Formatting: (ZZZ) ZZZ-ZZZZ x YYY
Phone Number Formatting for Storage: numbers only
Please Note: In all of my applications I usually do not store the phone numbers as the users enter them but rather format them into something the application can use and understand (I pack them and un-pack them with known heuristics).
USD: USA dollar format: $0000.00
Bytes: format a number given as bytes into a readable format such as 32MB
KiloBytes: format a number give as kilobytes into a readable format such as 23GB
echo Format::phoneNumberForStorage('480-373-6581').'
';
echo Format::phoneNumberForStorage('373-6581').'
';
echo Format::phoneNumber(Format::phoneNumberForStorage('800-959-0045')).'
';
echo Format::phoneNumber('3736581').'
';
echo Format::phoneNumber('3736581','480').'
';
echo Format::usd(56.32).'
';
echo Format::bytes(20375237).'
';
echo Format::kilobytes(20375237).'
';
This typical usage will output this:
4803736581
3736581
(800) 959-0045
373-6581
(480) 373-6581
$56.32
19.43 MB
19.43 GB
Thank you.
thank you, will certainly try it out.
Nice – very handy to have. Also loving your browser detection script – works like a dream!
Thanks, but I think you should add more features to it.