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. Link to comment https://forums.phpfreaks.com/topic/189172-php-string-function-help/ 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); Link to comment https://forums.phpfreaks.com/topic/189172-php-string-function-help/#findComment-998742 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! Link to comment https://forums.phpfreaks.com/topic/189172-php-string-function-help/#findComment-998752 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.