Skip to content

Instantly share code, notes, and snippets.

@drunkday
Created March 30, 2012 05:36
Show Gist options
  • Save drunkday/2246856 to your computer and use it in GitHub Desktop.
Save drunkday/2246856 to your computer and use it in GitHub Desktop.
PHP一个去空格的代码
<?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