KnowledgeHub
Questions
Tags
Users
Search
Alex Rivera
|
Logout
Edit Question
Title
Body
I had a problem on how to put dash in every 3rd character. For example, I want ABCDEF turn into ABC-DEF I have this code: $string = 'ABCDEF'; echo substr_replace(chunk_split($string,3),'-','3','2'); // the output is ABC-DEF However this code does not work if I add more characters to the $string variable such as ABCDEFGHI . If I use the above code, the output will be: ABC-DEF GHI
Tags (comma-separated)
Save Edits
Cancel