3v4l.org

run code in 300+ PHP versions simultaneously
<?php $s = "Huawei MatePad 11 (2021)"; $regex = "/\(([^()]+)\)|\h+/"; $result = preg_replace_callback($regex, function($m) { return array_key_exists(1, $m) ? $m[1] : '-'; }, $s); echo $result;
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/1gbDS
function name:  (null)
number of ops:  11
compiled vars:  !0 = $s, !1 = $regex, !2 = $result
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    3     0  E >   ASSIGN                                                   !0, 'Huawei+MatePad+11+%282021%29'
    4     1        ASSIGN                                                   !1, '%2F%5C%28%28%5B%5E%28%29%5D%2B%29%5C%29%7C%5Ch%2B%2F'
    5     2        INIT_FCALL                                               'preg_replace_callback'
          3        SEND_VAR                                                 !1
          4        DECLARE_LAMBDA_FUNCTION                          ~5      [0]
    7     5        SEND_VAL                                                 ~5
          6        SEND_VAR                                                 !0
    5     7        DO_ICALL                                         $6      
          8        ASSIGN                                                   !2, $6
    8     9        ECHO                                                     !2
    9    10      > RETURN                                                   1


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

End of Dynamic Function 0

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
146.81 ms | 1013 KiB | 14 Q