β

php 去除字符串中所有空格 制表符 换行符 回车符

Mindy 493 阅读
<?php

/*
$a = 3;
$b = 4;
$a ^= $b;
$b ^= $a;
$a ^= $b;
echo $a.'<===>'.$b;
*/

function trimall($str)//删除空格
{
$qian=array(" "," ","\t","\n","\r");$hou=array("","","","","");
return str_replace($qian,$hou,$str);
}

$a = "aavadf avdfasf vadfasfs avasdfsdaf ";

$x = "avsav vadvsd 你好faf vaf 你好 adv 你是谁 你好 ";

$b = trimall($x);

echo $b;


/*

Microsoft Windows [版本 6.1.7601]
版权所有 (c) 2009 Microsoft Corporation。保留所有权利。

C:\Users\ml>cd /d d:\

d:\>php swap.php
aavadfavdfasfvadfasfsavasdfsdaf
d:\>php swap.php
avsavvadvsd你好fafvaf你好adv你是谁你好
d:\>

*/
作者:Mindy
我是好人,好人就是我,我就是一码农Mindy

发表评论