Created
March 30, 2012 05:36
-
-
Save drunkday/2246856 to your computer and use it in GitHub Desktop.
PHP一个去空格的代码
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
function RemoveSpace($str){ | |
/* 获取字符串长度/转为循环次数 */ | |
$l=strlen($str); | |
for($i=0;$i<$l;$i++){ | |
/* 判断如果当前字符和下一个字符为空格,则当前字符为NUll */ | |
if($str[$i] == ' ' and $str[$i+1] == ' '){ | |
$str[$i] = ''; | |
} | |
} | |
return $str; | |
} | |
?> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment