How do you split a phone number input with the explode function if you are there's no separator like in this case 555-555-5555 where is a dash as opposed to 5555555555 where there's none?
I assume you would count the characters then explode?
I'd just use the substr function!
[php]
$num = 5556667777;
$one=substr($num,0,3); $two=substr($num,3,3); $three=substr($num,6,4);
$formated = $one.'-'.$two.'-'.$three;
echo $formated;
[/php]
I would use JS to handle the formatting and the double check the result w/ php. That way if they do put the dash in you can make sure it's formatted properly before it's submitted. I'm sure there are a million and one code snippets in google to help you with this. It's very common.
ok thanks for the suggestions.
no problem... here is on w/ jquery which is what I prefer:
http://stackoverflow.com/questions/8...-number-format
stack overflow is a great place to find this kind of stuff by the way.
Yeah love stackoverflow. Thanks for that link. Nice example.