Open In App

PHP mb_decode_numericentity() Function

Last Updated : 12 Apr, 2023
Improve
Improve
Like Article
Like
Save
Share
Report

The mb_decode_numericentity() is an inbuilt function in PHP, where the reference for the numeric string in HTML will be decoded into characters.

Syntax:

mb_decode_numericentity(string $string, array $map, ?string $encoding = null): string

Parameters:  This function has four parameters:

  • $string: This parameter specifies the string that is to be decoded.
  • $map: The code area that is to be transformed, is represented by the map, which is an array.
  • $encoding: The encoding parameter denotes the character encoding. If omitted or null, then the internal character encoding value will be used.

Return Values: The function return decoded string.

Example 1: The following code demonstrates the mb_decode_numericentity() function.

PHP




<?php
  
// Define a string with numeric entities
$str = 'ABC';
  
// Decode the string
$decoded_str = mb_decode_numericentity(
    $str, array(0x0, 0x10000, 0, 0xfffff), 'UTF-8');
  
// Display the decoded string
echo $decoded_str;
?>


Output:

ABC

Example 2: The following code demonstrates the mb_decode_numericentity() function.

PHP




<?php
  
// Define a string with numeric entities
$str = 'Hello World';
  
// Decode the string
$decoded_str = mb_decode_numericentity(
    $str, array(0x0, 0x10000, 0, 0xfffff), 'UTF-8');
  
// Display the decoded string
echo $decoded_str;
?>


Output:

Hello World

Reference: https://www.php.net/manual/en/function.mb-decode-numericentity.php#refsect1-function.mb-decode-numericentity-description



Like Article
Suggest improvement
Share your thoughts in the comments

Similar Reads