Home  >  Article  >  Backend Development  >  PHP reads the file content into a string and removes newlines, blank lines, and spaces at the beginning and end of the line (Zjmainstay original)_PHP tutorial

PHP reads the file content into a string and removes newlines, blank lines, and spaces at the beginning and end of the line (Zjmainstay original)_PHP tutorial

WBOY
WBOYOriginal
2016-07-21 15:16:581104browse

Copy code The code is as follows:

//Output:
aaaa,bbbb,cccc,dddd,eeee,ffff,gggg,hhhh,iiii,jjjj,kk kk,ll ll

//file.php content:
aaaa

cccc
dddd
eeee
ffff
gggg
hhhh
iiii
jjjj
kk kk
ll ll


//file.php replace space (x), Tab (T) effect
aaaa

TTTT
cccc
ddddT
xxxxxxxxxxxT
eeeexxxxxxxxxx
ffff
gggg
hhhhxxxxxxxx
xxxxxxxxiiii
xxxxxxxxjjjjxxxxxxx
kkxxxkkTT
xxxxllxxllTT
Txxxxxxxxxx
TTTxx

www.bkjia.comtruehttp: //www.bkjia.com/PHPjc/325785.htmlTechArticleCopy the code as follows: ?php /* *Read the file content into a string, and remove newlines and lines at the same time Trailing space on first line. */ header("Content-type: text/html; charset=utf-8"); echo preg_re...
Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn