3v4l.org

run code in 300+ PHP versions simultaneously
<?php /** * Converts numbers in string from western to eastern Arabic numerals. * * @param string $str Arbitrary text * @return string Text with western Arabic numerals converted into eastern Arabic numerals. */ function arabic_w2e($str) { $arabic_eastern = array('٠', '١', '٢', '٣', '٤', '٥', '٦', '٧', '٨', '٩'); $arabic_western = array('0', '1', '2', '3', '4', '5', '6', '7', '8', '9'); return str_replace($arabic_western, $arabic_eastern, $str); } /** * Converts numbers from eastern to western Arabic numerals. * * @param string $str Arbitrary text * @return string Text with eastern Arabic numerals converted into western Arabic numerals. */ function arabic_e2w($str) { $arabic_eastern = array('٠', '١', '٢', '٣', '٤', '٥', '٦', '٧', '٨', '٩'); $arabic_western = array('0', '1', '2', '3', '4', '5', '6', '7', '8', '9'); return str_replace($arabic_eastern, $arabic_western, $str); } //*/ Test echo arabic_w2e("1234567890"); // Outputs: ١٢٣٤٥٦٧٨٩٠ echo arabic_e2w("١٢٣٤٥٦٧٨٩٠"); // Outputs: 1234567890 //*/ ?>
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/aTYGI
function name:  (null)
number of ops:  9
compiled vars:  none
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   28     0  E >   INIT_FCALL                                               'arabic_w2e'
          1        SEND_VAL                                                 '1234567890'
          2        DO_FCALL                                      0  $0      
          3        ECHO                                                     $0
   29     4        INIT_FCALL                                               'arabic_e2w'
          5        SEND_VAL                                                 '%D9%A1%D9%A2%D9%A3%D9%A4%D9%A5%D9%A6%D9%A7%D9%A8%D9%A9%D9%A0'
          6        DO_FCALL                                      0  $1      
          7        ECHO                                                     $1
   32     8      > RETURN                                                   1

Function arabic_w2e:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/aTYGI
function name:  arabic_w2e
number of ops:  10
compiled vars:  !0 = $str, !1 = $arabic_eastern, !2 = $arabic_western
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    9     0  E >   RECV                                             !0      
   10     1        ASSIGN                                                   !1, <array>
   11     2        ASSIGN                                                   !2, <array>
   12     3        INIT_FCALL                                               'str_replace'
          4        SEND_VAR                                                 !2
          5        SEND_VAR                                                 !1
          6        SEND_VAR                                                 !0
          7        DO_ICALL                                         $5      
          8      > RETURN                                                   $5
   13     9*     > RETURN                                                   null

End of function arabic_w2e

Function arabic_e2w:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/aTYGI
function name:  arabic_e2w
number of ops:  10
compiled vars:  !0 = $str, !1 = $arabic_eastern, !2 = $arabic_western
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   21     0  E >   RECV                                             !0      
   22     1        ASSIGN                                                   !1, <array>
   23     2        ASSIGN                                                   !2, <array>
   24     3        INIT_FCALL                                               'str_replace'
          4        SEND_VAR                                                 !1
          5        SEND_VAR                                                 !2
          6        SEND_VAR                                                 !0
          7        DO_ICALL                                         $5      
          8      > RETURN                                                   $5
   25     9*     > RETURN                                                   null

End of function arabic_e2w

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
169.56 ms | 1448 KiB | 16 Q