SomeoneS SomeoneS - 1 year ago 76
PHP Question

Split sentence into words separated with commas

i have one sentence saved in database field , an i want to break it in words, but that words needs to be separated by coma, like this:

This, is, test, text

I tried something with explode() but it didnt do the work.

Answer Source

You could do

$text = "This is test text";
echo str_replace (" ", ", ", $text); // This, is, test, text
Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download