代码如下:
PHP /* *读取文件内容至字符串中,同时去除换行、行首行尾空格。 */ header("Content-type: text/html; charset=utf-8"); echo preg_replace('/((\s)*(\n)+(\s)*)/i',',file_get_contents('./file.PHP'));//End_PHP
//输出:
aaaa,bbbb,cccc,dddd,eeee,ffff,gggg,hhhh,iiii,jjjj,kk kk,ll ll //file.PHP内容:
aaaa cccc
dddd
eeee
ffff
gggg
hhhh
iiii
jjjj
kk kk
ll ll
//file.PHP替换空格(x)、Tab(T)效果
aaaa TTTT
cccc
ddddT
xxxxxxxxxxxT
eeeexxxxxxxxxx
ffff
gggg
hhhhxxxxxxxx
xxxxxxxxiiii
xxxxxxxxjjjjxxxxxxx
kkxxxkkTT
xxxxllxxllTT
Txxxxxxxxxx
TTTxx
原文链接:https://www.f2er.com/php/27076.html//输出:
aaaa,bbbb,cccc,dddd,eeee,ffff,gggg,hhhh,iiii,jjjj,kk kk,ll ll //file.PHP内容:
aaaa cccc
dddd
eeee
ffff
gggg
hhhh
iiii
jjjj
kk kk
ll ll
//file.PHP替换空格(x)、Tab(T)效果
aaaa TTTT
cccc
ddddT
xxxxxxxxxxxT
eeeexxxxxxxxxx
ffff
gggg
hhhhxxxxxxxx
xxxxxxxxiiii
xxxxxxxxjjjjxxxxxxx
kkxxxkkTT
xxxxllxxllTT
Txxxxxxxxxx
TTTxx