wmguk Posted March 30, 2008 Share Posted March 30, 2008 hey, Im trying to get a field output of 1234567890123456 to display as 1234 5678 9012 3456 only this is sometimes there could be anything between 16 and 24 in the original data output any ideas how i can take 4 digits then insert a space? - it will only ever be numbers. Link to comment https://forums.phpfreaks.com/topic/98718-add-a-space-between-each-4-digits/ Share on other sites More sharing options...
ridiculous Posted March 30, 2008 Share Posted March 30, 2008 http://us3.php.net/manual/en/function.str-replace.php Link to comment https://forums.phpfreaks.com/topic/98718-add-a-space-between-each-4-digits/#findComment-505176 Share on other sites More sharing options...
Barand Posted March 30, 2008 Share Posted March 30, 2008 <?php $str = '1234567890123456'; $a = str_split($str,4); echo join (' ', $a); ?> Link to comment https://forums.phpfreaks.com/topic/98718-add-a-space-between-each-4-digits/#findComment-505179 Share on other sites More sharing options...
wmguk Posted March 31, 2008 Author Share Posted March 31, 2008 Excellent thank you Just the job Link to comment https://forums.phpfreaks.com/topic/98718-add-a-space-between-each-4-digits/#findComment-505234 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.