PHP | IntlChar getBlockCode() Function
The IntlChar::getBlockCode() function is an inbuilt function in PHP which is used to get the Unicode allocation block containing the code point. This function returns the Unicode allocation block that contains the character.
Syntax:
int IntlChar::getBlockCode ( $codepoint )
Parameters: This function accepts a single parameter $codepoint which is mandatory. The $codepoint value is an integer values or character, which is encoded as a UTF-8 string.
Return Value: This function returns the block value for $codepoint. Some block value of codepoint are listed below:
- IntlChar::BLOCK_CODE_BASIC_LATIN
- IntlChar::BLOCK_CODE_GREEK
- IntlChar::BLOCK_CODE_MISCELLANEOUS_SYMBOLS
Below programs illustrate the IntlChar::getBlockCode() function in PHP:
Program 1:
PHP
<?php
var_dump(IntlChar::getBlockCode( "G" ) ===
IntlChar::BLOCK_CODE_BASIC_LATIN);
var_dump(IntlChar::getBlockCode( "ABC" ) ===
IntlChar::BLOCK_CODE_BASIC_LATIN);
var_dump(IntlChar::getBlockCode( "*" ) ===
IntlChar::BLOCK_CODE_GREEK);
var_dump(IntlChar::getBlockCode( "\u{2603}" ) ===
IntlChar::BLOCK_CODE_MISCELLANEOUS_SYMBOLS);
var_dump(IntlChar::getBlockCode( "@" ) ===
IntlChar::BLOCK_CODE_GREEK);
?>
|
Output:
bool(true)
bool(false)
bool(false)
bool(true)
bool(false)
Program 2:
PHP
<?php
$arr = array ( "G" , "GeeksforGeeks" , "^" , "1001" , "6" , "\n" );
foreach ( $arr as $val ){
var_dump(IntlChar::getBlockCode( $val ));
}
?>
|
Output:
int(1)
NULL
int(1)
NULL
int(1)
int(1)
Related Articles:
Reference: http://php.net/manual/en/intlchar.getblockcode.php
Last Updated :
04 Nov, 2020
Like Article
Save Article
Share your thoughts in the comments
Please Login to comment...