3v4l.org

run code in 200+ php & hhvm versions
Bugs & Features
<?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 $x = strval(date("H:i")); echo arabic_w2e($x); // Outputs: ١٢٣٤٥٦٧٨٩٠ // echo arabic_e2w("١٢٣٤يناير٥٦٧٨٩٠"); // Outputs: 1234567890 //*/ ?>
based on 57650
Finding entry points
Branch analysis from position: 0
Jump found. Position 1 = -2
filename:       /in/7DYo9
function name:  (null)
number of ops:  14
compiled vars:  !0 = $x
line     #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   9     0  E >   NOP                                                      
  21     1        NOP                                                      
  28     2        INIT_FCALL                                               'strval'
         3        INIT_FCALL                                               'date'
         4        SEND_VAL                                                 'H%3Ai'
         5        DO_ICALL                                         $1      
         6        SEND_VAR                                                 $1
         7        DO_ICALL                                         $2      
         8        ASSIGN                                                   !0, $2
  29     9        INIT_FCALL                                               'arabic_w2e'
        10        SEND_VAR                                                 !0
        11        DO_FCALL                                      0  $4      
        12        ECHO                                                     $4
        13      > RETURN                                                   1

Function arabic_w2e:
Finding entry points
Branch analysis from position: 0
Jump found. Position 1 = -2
filename:       /in/7DYo9
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
Jump found. Position 1 = -2
filename:       /in/7DYo9
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 7.3.0