A space character is considered an ICU space character if and only if it meets one of the following criteria:
- This is a Unicode delimiter character (categories "Z" = "Zs" or "Zl" or " Zp "), but it is also not a non-breaking space (U + 00A0 NBSP or U + 2007, space or U + 202F Narrow NBSP).
- U + 000A LINE FEED.
- U + 000B VERTICAL TABLE.
- U + 000C FORM FORM.
- U + 000D RETURN.
- U + 001C FILE SEPARATOR
- U + 001D GROUP SEPARATOR.
- U + 001E SEPARATOR ENTRY.
- U + 001F UNIT SEPARATOR.
- U + 0009 HORIZONTAL TABULATION.
Syntax:bool IntlChar::isWhitespace ($codepoint)
Parameters :This function accepts a single
$codepoint parameter which is required. The input parameter is a character or integer value encoded as
UTF-8 string.
Returned value:if
$codepoint is a whiteSpace character according to ICU, then it returns True, otherwise it returns False.Below programs illustrate the IntlChar::isWhitespace()function in PHP: Program 1:
// PHP code for illustration
// IntlChar::iswhitespace() function
// Enter capital letter
var_dump (IntlChar::iswhitespace (
"R"
));
// Enter a lowercase letter
var_dump (IntlChar::iswhitespace (
"r"
));
// Enter the Whitesapce character & quot; / n & quot;
var_dump (IntlChar::iswhitespace (
""
)) ;
// Enter the encoded string
var_dump (IntlChar::iswhitespace (
"u {00A0}"
));
// Enter a space character
var_dump (IntlChar::iswhitespace (
""
));
?>
Exit : bool (false) NULL bool (true) bool (false) bool (true)
Program 2:
// PHP code for IntlChar::iswhitespace()
// function
// Declare the $arr array
$arr
=
array
(
""
,
""
,
"^"
,
" "
,
" G "
);
// run loop for each array element
foreach
(
$arr
as
$val
) {
// Validate each element as code point data
var_dump (IntlChar::iswhitespace (
$val
));
}
?>
Exit : bool (true) bool (true) bool (false) bool (true) NULL
Related Articles: - IntlChar::isalpha() Function
- IntlChar::isbase() Function
- IntlChar::isblank() Function
- IntlChar::iscntrl() Function
Links: http://php.net/manual/en/iswhitespace