So I have this MySQL database and a table and in the rows there a lot of "," in them, and I wish when they are output on the screen with PHP to be switched to "
" instead of coma, how do I do that?
I mean, this is a example, it stands like this: hello,no,thanks and instead of being output like that I would like it to be output as: hello no thanks
How do I do that? Could someone do it for me? Would be very friendly.
Just use str_replace
Use
str_getcsv()
to make sure the escaped commas are processed correctly.Code:
Output
Do a php str_replace.
You could try the MySQL REPLACE function to have the data come back from your query already formatted like this:
Example:
In your case, something like:
Assuming there are no CSV quoting issues:
EDIT:
After seeing your rollback, i see that you actually want to replace the
,
with anewline
character such as\r
,\n
or\r\n
: