PHP code that reads file content into a string and processes it

WBOY
Release: 2016-07-25 09:04:42
Original
1217 people have browsed it
  1. /*

  2. *Read the file content into a string, while removing newlines and spaces at the beginning and end of the line.
  3. */
  4. header("Content-type: text/html; charset=utf-8");
  5. echo preg_replace('/((s)*(n)+(s)*)/i',',' ,file_get_contents('./file.php'));//End_php

  6. //Output:

  7. //aaaa,bbbb,cccc,dddd,eeee,ffff,gggg,hhhh,iiii, jjjj,kk kk,ll ll
  8. ?>

Copy code

file.php content: aaaa

cccc dddd eeee ffff ggg hhhh iiii jjjj kkkk ll ll

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

TTTT cccc ddddT xxxxxxxxxxxT eeeexxxxxxxxxx ffff ggg hhhhxxxxxxxxx xxxxxxxxxiii xxxxxxxxjjjjxxxxxxx kkxxxkkTT xxxxllxxllTT Txxxxxxxxxx TTTxx



source:php.cn
Statement of this Website
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
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template