<?php
$convmap = array (
int start_code1, int end_code1, int offset1, int mask1,
int start_code2, int end_code2, int offset2, int mask2,
// ........
int start_codeN, int end_codeN, int offsetN, int 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.
?>
// 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 = [ 0x0, 0xFFFF, 0, 0]; echo mb_decode_numericentity('m', $map ); // result "m" // if offsetN = 1 result "l" ; the more you increase the decimal the more it use OR operrand. $map_2 = [ 0x0, 0xFFFF, 60, 0]; echo mb_decode_numericentity('m', $map_2 ); // decode ( 1 ) result : "1"
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.
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.