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// PHP function to illustrate // the use of IntlChar::getBlockCode()// Input data is character typevar_dump(IntlChar::getBlockCode("G") === IntlChar::BLOCK_CODE_BASIC_LATIN);// Input data is string typevar_dump(IntlChar::getBlockCode("ABC") === IntlChar::BLOCK_CODE_BASIC_LATIN);// Input data is character typevar_dump(IntlChar::getBlockCode("*") === IntlChar::BLOCK_CODE_GREEK);// Input data is unicode character typevar_dump(IntlChar::getBlockCode("\u{2603}") === IntlChar::BLOCK_CODE_MISCELLANEOUS_SYMBOLS);// Input data is character typevar_dump(IntlChar::getBlockCode("@") === IntlChar::BLOCK_CODE_GREEK);?> |
Output:
bool(true) bool(false) bool(false) bool(true) bool(false)
Program 2:
PHP
<?php// PHP code to illustrate IntlChar::getBlockCode() // Declare an array $arr$arr = array("G", "zambiatek", "^", "1001", "6", "\n"); // Loop run for every array elementforeach ($arr as $val){ // Check each element as code point data var_dump(IntlChar::getBlockCode($val));}?> |
Output:
int(1) NULL int(1) NULL int(1) int(1)
Related Articles:
- PHP | IntlChar::iscntrl() Function
- PHP | IntlChar::totitle() Function
- PHP | IntlChar charType() Function
Reference: http://php.net/manual/en/intlchar.getblockcode.php
Whether you’re preparing for your first job interview or aiming to upskill in this ever-evolving tech landscape, zambiatek 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!



