<?php function loseSpace($pcon){ $pcon = preg_replace("/ /","",$pcon); $pcon = preg_replace("/ /","",$pcon); $pcon = preg_replace("/ /","",$pcon); $pcon = preg_replace("/\r\n/","",$pcon); $pcon = str_replace(chr(13),"",$pcon); $pcon = str_replace(chr(10),"",$pcon); $pcon = str_replace(chr(9),"",$pcon); return $pcon; } ?>
查看测试代码:
var_dump(" 开头有空格 中间 有空格 中间有换行符 \r\n 结束有空格 ");
结果是:
经过函数过滤后的代码:
var_dump(loseSpace(" 开头有空格 中间 有空格 中间有换行符 \r\n 结束有空格 "));
结果是:
时间: 2024-10-21 19:49:50