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

前端 未结 6 561
傲寒
傲寒 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:42

    Use str_getcsv() to make sure the escaped commas are processed correctly.

    Code:

    $input = "hello,no,thanks";
    $array = str_getcsv($input);
    $result = implode("\n",$array);
    

    Output

    hello
    no
    thanks
    

提交回复
热议问题