HomeMenu
Jesus · Bible · HTML · CSS · JS · PHP · SVG · Applications

mb_encode_numericentity

Description

The mb_encode_numericentity of Multibyte String for PHP encode character to HTML numeric string reference.

Syntax

mb_encode_numericentity(
    string $string,
    array $map,
    ?string $encoding = null,
    bool $hex = false
): string

Parameters

string

The string being encoded.

map

An array that specifies the code area to convert.

[int start1, int end1, int offset1, int mask1, ... int startN, int endN, int offsetN, int maskN]

encoding

The encoding parameter is the character encoding. If it is omitted or null, the internal character encoding value will be used.

hex

Whether the returned entity reference should be in hexadecimal notation. Otherwise, it is in decimal notation.

Return

The converted string.

Examples

1 · string map

<?

$string = 'string';
$map = [0, 0xff, 0, 0xff];

$return = mb_encode_numericentity($string, $map);

echo $return;
&#115;&#116;&#114;&#105;&#110;&#103;

2 · encoding

<?

$string = 'string';
$map = [0, 0xff, 0, 0xff];
$encoding = 'ASCII';

$return = mb_encode_numericentity($string, $map, $encoding);

echo $return;
&#115;&#116;&#114;&#105;&#110;&#103;

3 · hex

<?

$string = 'string';
$map = [0, 0xff, 0, 0xff];
$encoding = 'ASCII';
$hex = true;

$return = mb_encode_numericentity($string, $map, $encoding, $hex);

echo $return;
&#x73;&#x74;&#x72;&#x69;&#x6E;&#x67;