首页
学习
活动
专区
工具
TVP
发布
精选内容/技术社群/优惠产品,尽在小程序
立即前往

IntlChar::forDigit

(PHP 7)

IntlChar::forDigit — Get character representation for a given digit and radix

Description

代码语言:javascript
复制
public static int IntlChar::forDigit ( int $digit [, int $radix = 10 ] )

Determines the character representation for a specific digit in the specified radix.

If the value of radix is not a valid radix, or the value of digit is not a valid digit in the specified radix, the null character (U+0000) is returned.

The radix argument is valid if it is greater than or equal to 2 and less than or equal to 36. The digit argument is valid if 0 <= digit < radix.

If the digit is less than 10, then '0' + digit is returned. Otherwise, the value 'a' + digit - 10 is returned.

Parameters

digit

The number to convert to a character.

radix

The radix (defaults to 10).

Return Values

The character representation (as a string) of the specified digit in the specified radix.

Examples

Example #1 Testing different code points

代码语言:javascript
复制
<?php
var_dump(IntlChar::forDigit(0));
var_dump(IntlChar::forDigit(3));
var_dump(IntlChar::forDigit(3,?10));
var_dump(IntlChar::forDigit(10));
var_dump(IntlChar::forDigit(10,?16));
?>

The above example will output:

代码语言:javascript
复制
int(48)
int(51)
int(51)
int(0)
int(97)

See Also

  • IntlChar::digit() - Get the decimal digit value of a code point for a given radix
  • IntlChar::charDigitValue() - Get the decimal digit value of a decimal digit character
  • IntlChar::isdigit() - Check if code point is a digit character
  • IntlChar::PROPERTY_NUMERIC_TYPE

← IntlChar::foldCase

IntlChar::getBidiPairedBracket →

代码语言:txt
复制
 ? 1997–2017 The PHP Documentation Group

Licensed under the Creative Commons Attribution License v3.0 or later.

扫码关注腾讯云开发者

领取腾讯云代金券

http://www.vxiaotou.com