mb_decode_numericentity

(PHP 4 >= 4.0.6, PHP 5)

mb_decode_numericentityDecode HTML numeric string reference to character

Description

string mb_decode_numericentity ( string $str , array $convmap [, string $encoding = mb_internal_encoding() ] )

Convert numeric string reference of string str in a specified block to character.

Parameters

str

The string being decoded.

convmap

convmap is an array that specifies the code area to convert.

encoding

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

Return Values

The converted string.

Examples

Example #1 convmap example

<?php
$convmap 
= array (
   
int start_code1int end_code1int offset1int mask1,
   
int start_code2int end_code2int offset2int mask2,
   ........
   
int start_codeNint end_codeNint offsetNint maskN );
// Specify Unicode value for start_codeN and end_codeN
// Add offsetN to value and take bit-wise 'AND' with maskN, 
// then convert value to numeric string reference.
?>

See Also

Коментарии

Just two great functions for daily use:

/* Converts any HTML-entities into characters */
function my_numeric2character($t)
{
    $convmap = array(0x0, 0x2FFFF, 0, 0xFFFF);
    return mb_decode_numericentity($t, $convmap, 'UTF-8');
}
/* Converts any characters into HTML-entities */
function my_character2numeric($t)
{
    $convmap = array(0x0, 0x2FFFF, 0, 0xFFFF);
    return mb_encode_numericentity($t, $convmap, 'UTF-8');
}
print my_numeric2character('&#8217; &#7936; &#226;');
print my_character2numeric(' ? ? ');
2003-11-19 09:43:18
http://php5.kiev.ua/manual/ru/function.mb-decode-numericentity.html
note that at this time it seems that mb_decode_numericentity() only works with decimal entities and not hexadecimal entities.  This fact would have saved me a good hour of time in debugging.

For those who need to convert hex entities try first converting them all to decimal entities with a combination of the preg_replace() and hexdec() functions.
2006-04-19 12:05:18
http://php5.kiev.ua/manual/ru/function.mb-decode-numericentity.html
Be careful! 
In addition to translate numeric entities to chars on specified target encoding, this function encodes every character from input string to the specified target encodin, even if the characters are outside the range defined by the conversion map.
2020-06-05 03:49:28
http://php5.kiev.ua/manual/ru/function.mb-decode-numericentity.html
<?php

// the following documentation depending on understanding of the code source of php mbr
// first in order to optimise the work of php
// the string must contain "&" or else php won't bother trying to decode.
// for the map : int start_codeN, int end_codeN, int offsetN, int maskN
// the entity must be in the range [start_codeN, end_codeN] , if the entity is greater or less
// mb_decode_numericentity will ignore the decode process and return the $string as it is.
// in the late version of php, $map : "must have a multiple of 4 elements"

$map = [ 0x00xFFFF00];
echo 
mb_decode_numericentity('&#109;'$map ); // result "m"
// if offsetN = 1 result "l" ; the more you increase the decimal the more it use OR operrand.
$map_2 = [ 0x00xFFFF600];
echo 
mb_decode_numericentity('&#109;'$map_2 ); // decode ( &#49; ) result : "1"

// entity Reference to check the result : https://cs.stanford.edu/people/miles/iso8859.html#ISO

?>
2022-08-30 02:41:01
http://php5.kiev.ua/manual/ru/function.mb-decode-numericentity.html

    Поддержать сайт на родительском проекте КГБ