"Com str.php"의 두 판 사이의 차이

4번째 줄: 4번째 줄:
</source>
</source>
<source lang='php'>
<source lang='php'>
function merge_space($str) { return preg_replace( "/\s+/", " ", $str) };
function merge_space($str) { return preg_replace( "/\s+/", " ", $str) }
</source>
</source>
<source lang='php'>
<source lang='php'>

2013년 6월 13일 (목) 11:44 판

merge_space

$result = preg_replace( "/\s+/", " ", $str);
function merge_space($str) { return preg_replace( "/\s+/", " ", $str) }
function merge_space($str) {
	$repeat = true;
	while($repeat) {
		$temp = $str;
		$str = str_replace('  ', ' ', $str);
		if($temp == $str) $repeat = false;
	}
	return $str;
}
문서 댓글 ({{ doc_comments.length }})
{{ comment.name }} {{ comment.created | snstime }}