The IntlChar::isWhitespace() function is an inbuilt function in PHP which is used to check whether the given input character is a WhiteSpace character or not according to ICU. IntlChar access number utility function and used to access the information about Unicode Characters.
The White Space character is considered to ICU whitespace character if and only if it satisfies one of the following criteria:
- It is a Unicode Separator character (categories “Z” = “Zs” or “Zl” or “Zp”) but is not also a non-breaking space (U+00A0 NBSP or U+2007 Figure Space or U+202F Narrow NBSP).
- U+000A LINE FEED .
- U+000B VERTICAL TABULATION.
- U+000C FORM FEED.
- U+000D CARRIAGE RETURN.
- U+001C FILE SEPARATOR.
- U+001D GROUP SEPARATOR.
- U+001E RECORD SEPARATOR.
- U+001F UNIT SEPARATOR.
- U+0009 HORIZONTAL TABULATION.
Syntax:
bool IntlChar::isWhitespace( $codepoint )
Parameters: This function accepts s single parameter $codepoint which is mandatory. The input parameter is a character or integer value, which is encoded as a UTF-8 string.
Return Value: If $codepoint is a whiteSpace character according to ICU then it returns True, otherwise return False.
Below programs illustrate the IntlChar::isWhitespace() Function in PHP:
Program 1:
PHP
<?php
var_dump(IntlChar::iswhitespace( "R" ));
var_dump(IntlChar::iswhitespace( " r " ));
var_dump(IntlChar::iswhitespace( "\n" ));
var_dump(IntlChar::iswhitespace( "\u{00A0}" ));
var_dump(IntlChar::iswhitespace( " " ));
?>
|
Output:
bool(false)
NULL
bool(true)
bool(false)
bool(true)
Program 2:
PHP
<?php
$arr = array ( "\t" , "\n" , "^" , "\r" , "G\t" );
foreach ( $arr as $val ){
var_dump(IntlChar::iswhitespace( $val ));
}
?>
|
Output:
bool(true)
bool(true)
bool(false)
bool(true)
NULL
Related Articles:
References: http://php.net/manual/en/iswhitespace
Whether you're preparing for your first job interview or aiming to upskill in this ever-evolving tech landscape,
GeeksforGeeks Courses are your key to success. We provide top-quality content at affordable prices, all geared towards accelerating your growth in a time-bound manner. Join the millions we've already empowered, and we're here to do the same for you. Don't miss out -
check it out now!