3v4l.org

run code in 300+ PHP versions simultaneously
<?php function reverseEnglishWords($string) { return preg_replace_callback('/(?!\s)[^\p{Arabic}\r\n]+/u', function ($m) { $tmp = preg_replace_callback('~(\w+)([^\w\s]+)~', function($n) { return strrev($n[2]) . $n[1]; }, $m[0]); return implode(" ", array_reverse( preg_split('~\s+~u', $tmp, -1, PREG_SPLIT_NO_EMPTY) ) ); }, $string); } $s = " این یک تست جدید است Is my English line working just fine? I hope it does... Another one?! این یک جمله جدید است and this is to be continued in English... "; echo reverseEnglishWords($s);
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/t9THR
function name:  (null)
number of ops:  6
compiled vars:  !0 = $s
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   16     0  E >   ASSIGN                                                   !0, '%0A%D8%A7%DB%8C%D9%86+%DB%8C%DA%A9+%D8%AA%D8%B3%D8%AA+%D8%AC%D8%AF%DB%8C%D8%AF+%D8%A7%D8%B3%D8%AA%0AIs+my+English+line+working+just+fine%3F%0AI+hope+it+does...%0AAnother+one%3F%21%0A%D8%A7%DB%8C%D9%86+%DB%8C%DA%A9+%D8%AC%D9%85%D9%84%D9%87+%D8%AC%D8%AF%DB%8C%D8%AF+%D8%A7%D8%B3%D8%AA+and+this+is+to+be+continued+in+English...%0A'
   24     1        INIT_FCALL                                               'reverseenglishwords'
          2        SEND_VAR                                                 !0
          3        DO_FCALL                                      0  $2      
          4        ECHO                                                     $2
          5      > RETURN                                                   1

Function reverseenglishwords:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/t9THR
function name:  reverseEnglishWords
number of ops:  9
compiled vars:  !0 = $string
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    3     0  E >   RECV                                             !0      
    5     1        INIT_FCALL                                               'preg_replace_callback'
          2        SEND_VAL                                                 '%2F%28%3F%21%5Cs%29%5B%5E%5Cp%7BArabic%7D%5Cr%5Cn%5D%2B%2Fu'
          3        DECLARE_LAMBDA_FUNCTION                          ~1      [0]
   13     4        SEND_VAL                                                 ~1
          5        SEND_VAR                                                 !0
    5     6        DO_ICALL                                         $2      
   13     7      > RETURN                                                   $2
   14     8*     > RETURN                                                   null


Dynamic Functions:
Dynamic Function 0
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/t9THR
function name:  {closure}
number of ops:  24
compiled vars:  !0 = $m, !1 = $tmp
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    5     0  E >   RECV                                             !0      
    6     1        INIT_FCALL                                               'preg_replace_callback'
          2        SEND_VAL                                                 '%7E%28%5Cw%2B%29%28%5B%5E%5Cw%5Cs%5D%2B%29%7E'
          3        DECLARE_LAMBDA_FUNCTION                          ~2      [0]
    8     4        SEND_VAL                                                 ~2
          5        FETCH_DIM_R                                      ~3      !0, 0
          6        SEND_VAL                                                 ~3
    6     7        DO_ICALL                                         $4      
          8        ASSIGN                                                   !1, $4
    9     9        INIT_FCALL                                               'implode'
         10        SEND_VAL                                                 '+'
         11        INIT_FCALL                                               'array_reverse'
   10    12        INIT_FCALL                                               'preg_split'
         13        SEND_VAL                                                 '%7E%5Cs%2B%7Eu'
         14        SEND_VAR                                                 !1
         15        SEND_VAL                                                 -1
         16        SEND_VAL                                                 1
         17        DO_ICALL                                         $6      
         18        SEND_VAR                                                 $6
    9    19        DO_ICALL                                         $7      
   10    20        SEND_VAR                                                 $7
    9    21        DO_ICALL                                         $8      
   10    22      > RETURN                                                   $8
   13    23*     > RETURN                                                   null


Dynamic Functions:
Dynamic Function 0
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/t9THR
function name:  {closure}
number of ops:  9
compiled vars:  !0 = $n
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    6     0  E >   RECV                                             !0      
    7     1        INIT_FCALL                                               'strrev'
          2        FETCH_DIM_R                                      ~1      !0, 2
          3        SEND_VAL                                                 ~1
          4        DO_ICALL                                         $2      
          5        FETCH_DIM_R                                      ~3      !0, 1
          6        CONCAT                                           ~4      $2, ~3
          7      > RETURN                                                   ~4
    8     8*     > RETURN                                                   null

End of Dynamic Function 0

End of Dynamic Function 0

End of function reverseenglishwords

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
155.99 ms | 1022 KiB | 19 Q