$sanitizer->removeWhitespace() method

Remove or replace all whitespace from string

Available since version 3.0.105.

Usage

// basic usage
$string = $sanitizer->removeWhitespace(string $str);

// usage with all arguments
$string = $sanitizer->removeWhitespace(string $str, $options = []);

Arguments

NameType(s)Description
strstring

String to remove whitespace from

options (optional)array, string

Options to modify behavior, or specify string for replace option:

  • replace (string): Character(s) to replace whitespace with (default='').
  • collapse (bool): If using replace, collapse consecutive replace chars to single? (default=true)
  • trim (bool): If using replace, trim it from beginning and end? (default=true)
  • html (bool): Remove/replace HTML whitespace entities too? (default=true)
  • allow (array): Array of whitespace characters that may remain. (default=[])

Return value

string


$sanitizer methods and properties

API reference based on ProcessWire core version 3.0.236

Latest news

  • ProcessWire Weekly #532
    In the 532nd issue of ProcessWire Weekly we'll cover the latest core updates, check out a couple of brand-new third party modules, and more. Read on!
    Weekly.pw / 20 July 2024
  • Page List Custom Children module
    This simple module gives you the ability to customize the parent/child relationship as it appears in the admin page list, enabling child pages to appear under more than one parent.
    Blog / 28 June 2024
  • Subscribe to weekly ProcessWire news

“I am currently managing a ProcessWire site with 2 million+ pages. It’s admirably fast, and much, much faster than any other CMS we tested.” —Nickie, Web developer