Subscribe to RSS Feed

Code Snippets: Add comma’s to a string

Pretty commonly I’ll need to display a string of text that needs to be comma delineated using PHP.  This is the easiest way I have found to accomplish this. <?php $string = “test test2 test3 test4 test5 “; echo substr(str_replace(” “, “, “, $string), 0, -2); //outputs test, test2, test3, test4, test5 ?> Make sure [...]

Read the article