Open In App
Related Articles

PHP | IntlChar::charMirror() Function

Improve
Improve
Improve
Like Article
Like
Save Article
Save
Report issue
Report
The IntlChar::charMirror() function is an inbuilt function in PHP which is used to find the “mirror-image” character from the given input code point character, which maps the specified character. Syntax:
mixed IntlChar::charMirror( $codepoint )
Parameters: This function accepts a single parameter $codepoint which is mandatory. The input parameter is a character or integer value, which is encoded as a UTF-8 string. Return Value: This function returns another Unicode code point that may serve as a mirror-image substitute, or codepoint itself if there is no such mapping or the codepoint does not have the Bidi_Mirrored property. The function returns an integer unless code point was passed in UTF-8 string and a string will be returned. Below programs illustrate the IntlChar::charMirror() Function in PHP. Program 1:
<?php
// PHP code to illustrate
// IntlChar::charMirror ()function
  
// Input Alphabet codepoint character
var_dump(IntlChar::charMirror("A"));
var_dump(IntlChar::charMirror("B"));
  
// Input codepoint is Symbloic 
var_dump(IntlChar::charMirror("&"));
var_dump(IntlChar::charMirror("{"));
var_dump(IntlChar::charMirror("^"));
var_dump(IntlChar::charMirror("]"));
  
// Input codepoint is integer 
var_dump(IntlChar::charMirror("2"));
var_dump(IntlChar::charMirror("10"));
  
?>

                    
Output:
string(1) "A" 
string(1) "B" 
string(1) "&" 
string(1) "}" 
string(1) "^" 
string(1) "[" 
string(1) "2" 
NULL
Program 2:
<?php
// PHP code to illustrate
// IntlChar::charMirror() function
  
// Declare an array $arr
$arr = array("G", "Geek", "801", "7", "F", " \\", "/ ", "\t");
  
// Loop run for every array element
foreach ($arr as $val){
      
    // Check each element as code point data
    var_dump(IntlChar::charMirror($val));
}
?>

                    
Output:
string(1) "G" 
NULL 
NULL 
string(1) "7" 
string(1) "F" 
NULL 
NULL 
string(1) "    " 
Related Articles: Reference: http://php.net/manual/en/intlchar.charmirror.php

Last Updated : 03 Nov, 2020
Like Article
Save Article
Previous
Next
Share your thoughts in the comments
Similar Reads