How do I read a “,” as “
” in PHP/MySQL?

前端 未结 6 558
傲寒
傲寒 2021-01-27 10:55

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 \"
\" inste

6条回答
  •  别那么骄傲
    2021-01-27 11:34

    Assuming there are no CSV quoting issues:

    $newStr = str_replace( ',', '
    ', $string );

    EDIT:

    After seeing your rollback, i see that you actually want to replace the , with a newline character such as \r, \n or \r\n:

    $newStr = str_replace( ',', "\n", $string );
    

提交回复
热议问题