Re: Formating a string to telephone format - (123) 456 - 7890
| From: | Chris Moyer | Date: | Mon, 26 Jun 2000 13:30:06 +0000 |
| Subject: | Re: Formating a string to telephone format - (123) 456 - 7890 | ||
| References: | 1 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-3114@lists.php.net to get a copy of this message | ||
On Mon, Jun 26, 2000 at 09:19:13AM -0500, Sean Mathews wrote:
> This is surely very simple, but Im new. I need to create a function to
> format a variable length string to a telephone format. Thus 1234567890
> becomes (123) 456 - 7890, and 1234567 becomes 123 - 4567 etc etc. I havent
> been able to find any procedures to copy portions of strings. Please drop
> me a hint.
An easy way to do that would be to user substr(), it takes 2 or 3 arguments,
a string, the position to start the substring(starts at 0) and optionally the length
of the string..
so substr("1234567890", 0, 3) would return "123
-- Chris Moyer -- cmoyer@chekinc.com --
PHP Developer -- Chek.com