simonp Posted September 25, 2007 Share Posted September 25, 2007 Hi, I have a post string that has eight characters in and need to add five spaces in between each character Eg. $account = "12345678" I need $account = "1 2 3 4 5 6 7 8" What would be the best way to do this? Cheers Simon Quote Link to comment Share on other sites More sharing options...
Lumio Posted September 25, 2007 Share Posted September 25, 2007 <?php $s = '123456789'; //text $_s = ''; for($i=0;$i<strlen($s);$i++) { //get every single sign if ($i==strlen($s)-1) $_s .= substr($s, $i, 1); else $_s .= substr($s, $i, 1).str_repeat(' ', 5); //add 5 spaces } $s = $_s; echo $ss; ?> Quote Link to comment Share on other sites More sharing options...
simonp Posted September 25, 2007 Author Share Posted September 25, 2007 Thanks Lumio - that's ace. Cheers Simon 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.