normalize_whitespace()
Normalize EOL characters and strip duplicate whitespace.
1 time — 0.000123 sec (fast) | 50000 times — 0.04 sec (speed of light)
No Hooks.
Return
String
. The normalized string.
Usage
normalize_whitespace( $str );
- $str(string) (required)
- The string to normalize.
Changelog
Since 2.7.0 | Introduced. |
Code of normalize_whitespace() normalize whitespace WP 5.9.3
function normalize_whitespace( $str ) { $str = trim( $str ); $str = str_replace( "\r", "\n", $str ); $str = preg_replace( array( '/\n+/', '/[ \t]+/' ), array( "\n", ' ' ), $str ); return $str; }