A WordPress-centric search engine for devs and theme authors



normalize_whitespace ›

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:

Normalize EOL characters and strip 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;
}