- preg_replace: documentation ( source)
<?php
$string = "accept
add
admire
admit
advise
afford
agree
alert
allow
amuse
analyse
announce
annoy
answer
apologise
appear
applaud
appreciate
approve
argue
arrange
arrest
arrive
ask
attach
attack
attempt
attend
attract
avoid";
$string = preg_replace("/\s/", ",", $string);
echo $string;