Open In App

PHP mb_decode_numericentity() Function

Last Updated : 12 Apr, 2023
Comments
Improve
Suggest changes
Like Article
Like
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 = '&#65;&#66;&#67;';

// 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 = '&#72;&#101;&#108;&#108;&#111;&#32;&#87;&#111;&#114;&#108;&#100;';

// 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


Next Article

Similar Reads