3v4l.org

run code in 300+ PHP versions simultaneously
<?php $string = 'Testing giving dancing 喝 喝 passing 制图 giving 跑步 吃'; // split by a space into an array $explosion = explode(' ', $string); $normalWords = []; $chineseWords = []; // loop through the array foreach ($explosion as $debris) { // if not normal alphabet characters if (!preg_match('#[a-zA-Z]+#', $debris) && !in_array($debris, $chineseWords)) { // add to chinese words array if not already in the array $chineseWords[] = $debris; } elseif (preg_match('#[a-zA-Z]+#', $debris) && !in_array($debris, $normalWords)) { // add to normal words array if not already in the array $normalWords[] = $debris; } } // reverse the chinese characters like you wanted $chineseWords = array_reverse($chineseWords); // Piece it all back together $string = implode(' ', $normalWords) . ' ' . implode(' ', $chineseWords); // and output echo $string;
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 77) Position 1 = 9, Position 2 = 41
Branch analysis from position: 9
2 jumps found. (Code = 78) Position 1 = 10, Position 2 = 41
Branch analysis from position: 10
2 jumps found. (Code = 46) Position 1 = 16, Position 2 = 22
Branch analysis from position: 16
2 jumps found. (Code = 43) Position 1 = 23, Position 2 = 26
Branch analysis from position: 23
1 jumps found. (Code = 42) Position 1 = 40
Branch analysis from position: 40
1 jumps found. (Code = 42) Position 1 = 9
Branch analysis from position: 9
Branch analysis from position: 26
2 jumps found. (Code = 46) Position 1 = 31, Position 2 = 37
Branch analysis from position: 31
2 jumps found. (Code = 43) Position 1 = 38, Position 2 = 40
Branch analysis from position: 38
1 jumps found. (Code = 42) Position 1 = 9
Branch analysis from position: 9
Branch analysis from position: 40
Branch analysis from position: 37
Branch analysis from position: 22
Branch analysis from position: 41
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 41
filename:       /in/FWQWG
function name:  (null)
number of ops:  59
compiled vars:  !0 = $string, !1 = $explosion, !2 = $normalWords, !3 = $chineseWords, !4 = $debris
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    3     0  E >   ASSIGN                                                   !0, 'Testing+giving+dancing+%E5%96%9D+%E5%96%9D+passing+%E5%88%B6%E5%9B%BE+giving+%E8%B7%91%E6%AD%A5+%E5%90%83'
    6     1        INIT_FCALL                                               'explode'
          2        SEND_VAL                                                 '+'
          3        SEND_VAR                                                 !0
          4        DO_ICALL                                         $6      
          5        ASSIGN                                                   !1, $6
    8     6        ASSIGN                                                   !2, <array>
    9     7        ASSIGN                                                   !3, <array>
   12     8      > FE_RESET_R                                       $10     !1, ->41
          9    > > FE_FETCH_R                                               $10, !4, ->41
   15    10    >   INIT_FCALL                                               'preg_match'
         11        SEND_VAL                                                 '%23%5Ba-zA-Z%5D%2B%23'
         12        SEND_VAR                                                 !4
         13        DO_ICALL                                         $11     
         14        BOOL_NOT                                         ~12     $11
         15      > JMPZ_EX                                          ~12     ~12, ->22
         16    >   INIT_FCALL                                               'in_array'
         17        SEND_VAR                                                 !4
         18        SEND_VAR                                                 !3
         19        DO_ICALL                                         $13     
         20        BOOL_NOT                                         ~14     $13
         21        BOOL                                             ~12     ~14
         22    > > JMPZ                                                     ~12, ->26
   17    23    >   ASSIGN_DIM                                               !3
         24        OP_DATA                                                  !4
         25      > JMP                                                      ->40
   18    26    >   INIT_FCALL                                               'preg_match'
         27        SEND_VAL                                                 '%23%5Ba-zA-Z%5D%2B%23'
         28        SEND_VAR                                                 !4
         29        DO_ICALL                                         $16     
         30      > JMPZ_EX                                          ~17     $16, ->37
         31    >   INIT_FCALL                                               'in_array'
         32        SEND_VAR                                                 !4
         33        SEND_VAR                                                 !2
         34        DO_ICALL                                         $18     
         35        BOOL_NOT                                         ~19     $18
         36        BOOL                                             ~17     ~19
         37    > > JMPZ                                                     ~17, ->40
   20    38    >   ASSIGN_DIM                                               !2
         39        OP_DATA                                                  !4
   12    40    > > JMP                                                      ->9
         41    >   FE_FREE                                                  $10
   25    42        INIT_FCALL                                               'array_reverse'
         43        SEND_VAR                                                 !3
         44        DO_ICALL                                         $21     
         45        ASSIGN                                                   !3, $21
   28    46        INIT_FCALL                                               'implode'
         47        SEND_VAL                                                 '+'
         48        SEND_VAR                                                 !2
         49        DO_ICALL                                         $23     
         50        CONCAT                                           ~24     $23, '+'
         51        INIT_FCALL                                               'implode'
         52        SEND_VAL                                                 '+'
         53        SEND_VAR                                                 !3
         54        DO_ICALL                                         $25     
         55        CONCAT                                           ~26     ~24, $25
         56        ASSIGN                                                   !0, ~26
   31    57        ECHO                                                     !0
   32    58      > RETURN                                                   1

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
149.07 ms | 1400 KiB | 23 Q