normalize_whitespace( string $str ): string

Normalizes EOL characters and strips duplicate whitespace.


Parameters

$str string Required
The string to normalize.

Top ↑

Return

string The normalized string.


Top ↑

Source

File: wp-includes/formatting.php. View all references

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


Top ↑

Changelog

Changelog
Version Description
2.7.0 Introduced.

Top ↑

User Contributed Notes

You must log in before being able to contribute a note or feedback.