PHP | IntlChar::charDigitValue() Function
The IntlChar::charDigitValue() function is an inbuilt function in PHP which is used to return the decimal digit value from a decimal digit character. Where the general category decimal digit numbers and “Nd” is Numeric_Type of Decimal.
Syntax:
int IntlChar::charDigitValue( $codepoint )
Parameters: This function accepts a single parameter $codepoint which is mandotary. The input parameter is a character or integer value, which is encoded as a UTF-8 string.
Return Value: If $codepoint is decimal digit value then returns True otherwise return -1.
Below programs illustrate the IntlChar::charDigitValue() Function in PHP.
Program 1:
<?php // PHP code to illustrate IntlChar::charDigitValue // function //Input int codepoint value var_dump(IntlChar::charDigitValue("\u{2025}")); echo "<br>"; //Input character codepoint value var_dump(IntlChar::charDigitValue("2345")); echo "<br>"; //Input int codepoint value var_dump(IntlChar::charDigitValue("\u{0774}")); echo "<br>"; //Input int codepoint value var_dump(IntlChar::charDigitValue("2")); echo "<br>"; //Input character codepoint value var_dump(IntlChar::charDigitValue("Geeks")); echo "<br>"; //Input character codepoint value var_dump(IntlChar::charDigitValue("\u{0E66}")); echo "<br>"; //Input Empty codepoint value var_dump(IntlChar::charDigitValue(" ")); ?> |
Output:
int(-1) NULL int(-1) int(2) NULL int(-1) int(-1)
Program 2:
<?php // PHP code to illustrate // IntlChar::charDigitValue() function // Declare an array $arr $arr = array("^", "2345", "6", "\n"); // Loop run for every array element foreach ($arr as $val){ // Check each element as code point data var_dump(IntlChar::charDigitValue($val)); echo "<br>"; } ?> |
Output:
int(-1) NULL int(6) int(-1)
Related Articles:
- IntlChar::isalpha() Function
- IntlChar::isbase() Function
- IntlChar::isblank() Function
- IntlChar::iscntrl() Function
Reference: http://php.net/manual/en/intlchar.chardigitvalue.php
Recommended Posts:
- How to call a function that return another function in JavaScript ?
- How to Check a Function is a Generator Function or not using JavaScript ?
- How to get the function name from within that function using JavaScript ?
- How to get the function name inside a function in PHP ?
- PHP | sin( ) Function
- D3.js | d3.max() function
- p5.js | str() function
- PHP | cos( ) Function
- CSS | url() Function
- PHP | abs() Function
- PHP | Ds\Map get() Function
- PHP Ds\Map sum() Function
- D3.js | d3.map.set() Function
- p5.js | hex() function
- PHP | Ds\Map first() Function
If you like GeeksforGeeks and would like to contribute, you can also write an article using contribute.geeksforgeeks.org or mail your article to contribute@geeksforgeeks.org. See your article appearing on the GeeksforGeeks main page and help other Geeks.
Please Improve this article if you find anything incorrect by clicking on the "Improve Article" button below.

