will35010 Posted January 20, 2010 Share Posted January 20, 2010 I need to know which function I can use to add character to a string. I want to do the opposite of what explode does. example: 123456789 I want it to do this: 123-45-6789 Thanks. Quote Link to comment Share on other sites More sharing options...
Buddski Posted January 20, 2010 Share Posted January 20, 2010 You can use join with substr calls.. $str = '123456789'; $array = array(substr($str,0,3),substr($str,3,2),substr($str,5)); echo join('-',$array); Quote Link to comment Share on other sites More sharing options...
will35010 Posted January 20, 2010 Author Share Posted January 20, 2010 You can use join with substr calls.. $str = '123456789'; $array = array(substr($str,0,3),substr($str,3,2),substr($str,5)); echo join('-',$array); Thank you! 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.