我需要从一个函数的500字的垂直列表中创建一个水平列表

I'm creating a 'bad words' filter as str_ireplace function and I have a list of about 500 bad words.. all in a long vertical list. Any idea how I could quickly and easily create a horizontal, comma-delimited formatted list without manually typing a comma after every word and backspacing?

And yes.. I could probably do this in 20 minutes, but I've had this problem before so I'm asking for all the future times I run into this too.

I'd just use find and replace. If whatever editor you're using for your coding can't cope with finding carriage returns try Word, Notepad++, etc.

In php it would be something like:

str_replace(array("", "
", "
"), ", ", $string);

Or

$file = file("list.txt");
print_r($file);

Or, if you want to use bash for that, this would be the thing:

sed -e :a -e '$!N;s/
/, /;ta' list.txt
file_put_contents('filename', implode(',', file('filename', FILE_IGNORE_NEW_LINES)));

This code rewrite your file exactly as you want