用换行符替换逗号并写入文本文件 [英] Replace comma with newline and write to text file

查看:39
本文介绍了用换行符替换逗号并写入文本文件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想在数据库上取值并用换行符替换逗号,然后写入文本文件.

I want to take value on the database and replace the comma with a newline and then write to a text file.

示例:

SELECT column FROM table WHERE ID = 6
Result: Monday,Tuesday,Wednesday,Thursday,Friday

我希望它然后删除逗号并使用换行符写入 .txt 文件.

I want it to then remove the commas and write to a .txt file with newline.

结果:

Monday

Tuesday

Wednesday

Thursday

Friday

希望这是有道理的.

推荐答案

使用类似的东西

file_put_contents("file.txt", str_replace(",", "\r\n", $string));

这篇关于用换行符替换逗号并写入文本文件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆