php reads the contents of the file into the string while removing the newline blank line and space at the beginning and end of the line (Zjmainstay original)

  • 2020-05-19 04:20:34
  • OfStack

 
<?php  /*   * Read the contents of the file into the string, and remove the Spaces at the beginning and end of the line.  */ header("Content-type: text/html; charset=utf-8"); echo preg_replace('/((\s)*(\n)+(\s)*)/i',',',file_get_contents('./file.php'));//End_php 
// The 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 the blank space (x) , Tab(T) The effect  
aaaa 

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


Related articles: