3v4l.org

run code in 300+ PHP versions simultaneously
<?php function uniqueNoEmpty($array) { return array_unique(array_filter($array, 'strlen')); } $original_string = 'one two three 喞 喝 four 刷囿 two 跏正 吁'; if (!preg_match_all('~(\p{Han}+)|(\S+)~u', $original_string, $out)) { echo 'no qualifying strings'; } else { $singleBytes = uniqueNoEmpty($out[2]) ?? []; $multiBytes = array_reverse(uniqueNoEmpty($out[1])); echo implode(' ', array_merge($singleBytes,$multiBytes)); }
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 43) Position 1 = 8, Position 2 = 10
Branch analysis from position: 8
1 jumps found. (Code = 42) Position 1 = 34
Branch analysis from position: 34
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 10
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/99NV4
function name:  (null)
number of ops:  35
compiled vars:  !0 = $original_string, !1 = $out, !2 = $singleBytes, !3 = $multiBytes
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    6     0  E >   ASSIGN                                                   !0, 'one+two+three+%E5%96%9E+%E5%96%9D+four+%E5%88%B7%E5%9B%BF+two+%E8%B7%8F%E6%AD%A3+%E5%90%81'
    8     1        INIT_FCALL                                               'preg_match_all'
          2        SEND_VAL                                                 '%7E%28%5Cp%7BHan%7D%2B%29%7C%28%5CS%2B%29%7Eu'
          3        SEND_VAR                                                 !0
          4        SEND_REF                                                 !1
          5        DO_ICALL                                         $5      
          6        BOOL_NOT                                         ~6      $5
          7      > JMPZ                                                     ~6, ->10
    9     8    >   ECHO                                                     'no+qualifying+strings'
    8     9      > JMP                                                      ->34
   11    10    >   INIT_FCALL                                               'uniquenoempty'
         11        FETCH_DIM_R                                      ~7      !1, 2
         12        SEND_VAL                                                 ~7
         13        DO_FCALL                                      0  $8      
         14        COALESCE                                         ~9      $8
         15        QM_ASSIGN                                        ~9      <array>
         16        ASSIGN                                                   !2, ~9
   12    17        INIT_FCALL                                               'array_reverse'
         18        INIT_FCALL                                               'uniquenoempty'
         19        FETCH_DIM_R                                      ~11     !1, 1
         20        SEND_VAL                                                 ~11
         21        DO_FCALL                                      0  $12     
         22        SEND_VAR                                                 $12
         23        DO_ICALL                                         $13     
         24        ASSIGN                                                   !3, $13
   14    25        INIT_FCALL                                               'implode'
         26        SEND_VAL                                                 '+'
         27        INIT_FCALL                                               'array_merge'
         28        SEND_VAR                                                 !2
         29        SEND_VAR                                                 !3
         30        DO_ICALL                                         $15     
         31        SEND_VAR                                                 $15
         32        DO_ICALL                                         $16     
         33        ECHO                                                     $16
   15    34    > > RETURN                                                   1

Function uniquenoempty:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/99NV4
function name:  uniqueNoEmpty
number of ops:  10
compiled vars:  !0 = $array
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    2     0  E >   RECV                                             !0      
    3     1        INIT_FCALL                                               'array_unique'
          2        INIT_FCALL                                               'array_filter'
          3        SEND_VAR                                                 !0
          4        SEND_VAL                                                 'strlen'
          5        DO_ICALL                                         $1      
          6        SEND_VAR                                                 $1
          7        DO_ICALL                                         $2      
          8      > RETURN                                                   $2
    4     9*     > RETURN                                                   null

End of function uniquenoempty

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
248.99 ms | 1010 KiB | 21 Q