wpseek.com
A WordPress-centric search engine for devs and theme authors



normalize_whitespace › WordPress Function

Since2.7.0
Deprecatedn/a
normalize_whitespace ( $str )
Parameters:
  • (string) $str The string to normalize.
    Required: Yes
Returns:
  • (string) The normalized string.
Defined at:
Codex:

Normalizes EOL characters and strips duplicate whitespace.



Source

function normalize_whitespace( $str ) {
	$str = trim( $str );
	$str = str_replace( "\r", "\n", $str );
	$str = preg_replace( array( '/\n+/', '/[ \t]+/' ), array( "\n", ' ' ), $str );
	return $str;
}