Tips:点此可运行HTML源码

php读取文件内容至字符串中,同时去除换行、空行、行首行尾空格(原创自Zjmainstay)

<?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 bbbb cccc dddd eeee ffff gggg hhhh iiii jjjj kk kk ll ll //file.php替换空格(x)、Tab(T)效果 aaaa bbbb TTTT cccc ddddT xxxxxxxxxxxT eeeexxxxxxxxxx ffff gggg hhhhxxxxxxxx xxxxxxxxiiii xxxxxxxxjjjjxxxxxxx kkxxxkkTT xxxxllxxllTT Txxxxxxxxxx TTTxx
posted @ 2012-07-12 13:26  Zjmainstay  阅读(628)  评论(0编辑  收藏  举报