3v4l.org

run code in 300+ PHP versions simultaneously
<?php function isArrayFieldSet(array $array, $field, $separator = '/') { if (strpos($field, $separator) !== false) { $path = explode($separator, $field); $field = array_shift($path); if (!is_null($field) && isset($array[$field])) { if (count($path) > 0) { return isArrayFieldSet($array[$field], implode($separator, $path), $separator); } return true; } else { return false; } } return isset($array[$field]); } $array = [ 'a' => 'test', 'b' => [ 'b2' => 123, 'b3' => [ 'test' => true ] ] ]; $shouldPass = [ 'a', 'b', 'b/b2', 'b/b3', 'b/b3/test' ]; $shouldNotPass = [ 'c', 'b/b1', 'b/b2/bx', 'b/b3/test/x', 'c/L1', 'a/k15', ]; for ($i = 0; $i < 100; $i++) { foreach ($shouldPass as $test) { isArrayFieldSet($array, $test, '/'); } foreach ($shouldNotPass as $test) { isArrayFieldSet($array, $test, '/'); } }
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 42) Position 1 = 24
Branch analysis from position: 24
2 jumps found. (Code = 44) Position 1 = 26, Position 2 = 5
Branch analysis from position: 26
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 5
2 jumps found. (Code = 77) Position 1 = 6, Position 2 = 13
Branch analysis from position: 6
2 jumps found. (Code = 78) Position 1 = 7, Position 2 = 13
Branch analysis from position: 7
1 jumps found. (Code = 42) Position 1 = 6
Branch analysis from position: 6
Branch analysis from position: 13
2 jumps found. (Code = 77) Position 1 = 15, Position 2 = 22
Branch analysis from position: 15
2 jumps found. (Code = 78) Position 1 = 16, Position 2 = 22
Branch analysis from position: 16
1 jumps found. (Code = 42) Position 1 = 15
Branch analysis from position: 15
Branch analysis from position: 22
2 jumps found. (Code = 44) Position 1 = 26, Position 2 = 5
Branch analysis from position: 26
Branch analysis from position: 5
Branch analysis from position: 22
Branch analysis from position: 13
filename:       /in/WQ1KE
function name:  (null)
number of ops:  27
compiled vars:  !0 = $array, !1 = $shouldPass, !2 = $shouldNotPass, !3 = $i, !4 = $test
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   23     0  E >   ASSIGN                                                   !0, <array>
   33     1        ASSIGN                                                   !1, <array>
   41     2        ASSIGN                                                   !2, <array>
   50     3        ASSIGN                                                   !3, 0
          4      > JMP                                                      ->24
   51     5    > > FE_RESET_R                                       $9      !1, ->13
          6    > > FE_FETCH_R                                               $9, !4, ->13
          7    >   INIT_FCALL                                               'isarrayfieldset'
          8        SEND_VAR                                                 !0
          9        SEND_VAR                                                 !4
         10        SEND_VAL                                                 '%2F'
         11        DO_FCALL                                      0          
         12      > JMP                                                      ->6
         13    >   FE_FREE                                                  $9
   52    14      > FE_RESET_R                                       $11     !2, ->22
         15    > > FE_FETCH_R                                               $11, !4, ->22
         16    >   INIT_FCALL                                               'isarrayfieldset'
         17        SEND_VAR                                                 !0
         18        SEND_VAR                                                 !4
         19        SEND_VAL                                                 '%2F'
         20        DO_FCALL                                      0          
         21      > JMP                                                      ->15
         22    >   FE_FREE                                                  $11
   50    23        PRE_INC                                                  !3
         24    >   IS_SMALLER                                               !3, 100
         25      > JMPNZ                                                    ~14, ->5
   53    26    > > RETURN                                                   1

Function isarrayfieldset:
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 43) Position 1 = 9, Position 2 = 42
Branch analysis from position: 9
2 jumps found. (Code = 46) Position 1 = 21, Position 2 = 23
Branch analysis from position: 21
2 jumps found. (Code = 43) Position 1 = 24, Position 2 = 41
Branch analysis from position: 24
2 jumps found. (Code = 43) Position 1 = 27, Position 2 = 39
Branch analysis from position: 27
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 39
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 41
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 23
Branch analysis from position: 42
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/WQ1KE
function name:  isArrayFieldSet
number of ops:  45
compiled vars:  !0 = $array, !1 = $field, !2 = $separator, !3 = $path
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    3     0  E >   RECV                                             !0      
          1        RECV                                             !1      
          2        RECV_INIT                                        !2      '%2F'
    5     3        INIT_FCALL                                               'strpos'
          4        SEND_VAR                                                 !1
          5        SEND_VAR                                                 !2
          6        DO_ICALL                                         $4      
          7        TYPE_CHECK                                  1018          $4
          8      > JMPZ                                                     ~5, ->42
    6     9    >   INIT_FCALL                                               'explode'
         10        SEND_VAR                                                 !2
         11        SEND_VAR                                                 !1
         12        DO_ICALL                                         $6      
         13        ASSIGN                                                   !3, $6
    7    14        INIT_FCALL                                               'array_shift'
         15        SEND_REF                                                 !3
         16        DO_ICALL                                         $8      
         17        ASSIGN                                                   !1, $8
    9    18        TYPE_CHECK                                    2  ~10     !1
         19        BOOL_NOT                                         ~11     ~10
         20      > JMPZ_EX                                          ~11     ~11, ->23
         21    >   ISSET_ISEMPTY_DIM_OBJ                         0  ~12     !0, !1
         22        BOOL                                             ~11     ~12
         23    > > JMPZ                                                     ~11, ->41
   10    24    >   COUNT                                            ~13     !3
         25        IS_SMALLER                                               0, ~13
         26      > JMPZ                                                     ~14, ->39
   11    27    >   INIT_FCALL_BY_NAME                                       'isArrayFieldSet'
         28        CHECK_FUNC_ARG                                           
         29        FETCH_DIM_FUNC_ARG                               $15     !0, !1
         30        SEND_FUNC_ARG                                            $15
         31        INIT_FCALL                                               'implode'
         32        SEND_VAR                                                 !2
         33        SEND_VAR                                                 !3
         34        DO_ICALL                                         $16     
         35        SEND_VAR_NO_REF_EX                                       $16
         36        SEND_VAR_EX                                              !2
         37        DO_FCALL                                      0  $17     
         38      > RETURN                                                   $17
   13    39    > > RETURN                                                   <true>
         40*       JMP                                                      ->42
   15    41    > > RETURN                                                   <false>
   19    42    >   ISSET_ISEMPTY_DIM_OBJ                         0  ~18     !0, !1
         43      > RETURN                                                   ~18
   20    44*     > RETURN                                                   null

End of function isarrayfieldset

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
162.27 ms | 1407 KiB | 23 Q