PHP | IntlChar hasBinaryProperty() function
Last Updated :
27 Aug, 2019
The IntlChar::hasBinaryProperty() function is an inbuilt function in PHP which is used to checks a binary Unicode property for a code point.
Syntax:
bool IntlChar::hasBinaryProperty( $codepoint, $property )
Parameters: This function accepts two parameters as mentioned above and described below:
- $codepoint: The $codepoint value is an integer values or character, which is encoded as a UTF-8 string.
- $property: This stores the IntlChar::PROPERTY_* constants.
Return Value: This function returns boolean value (true or false) based on binary Unicode property.
Below programs illustrate the IntlChar::hasBinaryProperty() function in PHP:
Program 1:
<?php
var_dump(IntlChar::hasBinaryProperty( "G" , IntlChar::PROPERTY_ALPHABETIC));
var_dump(IntlChar::hasBinaryProperty( "Geeks" , IntlChar::PROPERTY_ALPHABETIC));
var_dump(IntlChar::hasBinaryProperty( "}" , IntlChar::PROPERTY_BIDI_MIRRORED));
var_dump(IntlChar::hasBinaryProperty( "%" , IntlChar::PROPERTY_BIDI_MIRRORED));
?>
|
Output:
bool(true)
NULL
bool(true)
bool(false)
Program 2:
<?php
$arr = array ( "A" , "{" , "^" , ")" , "6" , "Geeks" , "))" );
foreach ( $arr as $val ){
var_dump(IntlChar::hasBinaryProperty( $val ,
IntlChar::PROPERTY_BIDI_MIRRORED));
}
?>
|
Output:
bool(false)
bool(true)
bool(false)
bool(true)
bool(false)
NULL
NULL
Reference: https://www.php.net/manual/en/intlchar.hasbinaryproperty.php
Share your thoughts in the comments
Please Login to comment...