$sanitizerremoveWhitespace()

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.251