briant Posted May 8, 2009 Share Posted May 8, 2009 I'm sure there's a function for this, I just don't know what it is. In the database I have a 13 character number. I want to add a dash after the 3rd number. 948-3750279853 I tried wordwrap, that kind worked but it added a dash after every 3rd. number_format is a no. I was going to do a substr twice but that's kind of sloppy. There must be a better way. Thanks for any help in advanced. Quote Link to comment Share on other sites More sharing options...
RichardRotterdam Posted May 8, 2009 Share Posted May 8, 2009 you can use substr to split it at a position and then put a dash in between Quote Link to comment Share on other sites More sharing options...
thebadbad Posted May 8, 2009 Share Posted May 8, 2009 Another way to do it is with sscanf() and implode(): <?php $str = '9483750279853'; $str = implode(sscanf($str, '%3s%10s'), '-'); ?> Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.