3v4l.org

run code in 300+ PHP versions simultaneously
<?php class RegularExpression extends \RecursiveRegexIterator { /** * Get accept status. * * Match the current value or the current key (depends of the flag) against * the regular expression. Please, see the \RegexIterator::accept method. * * Fix https://bugs.php.net/68128. * * @access public * @return bool */ public function accept ( ) { return true === $this->hasChildren() || true === parent::accept(); } } $rArrayIterator = new RecursiveArrayIterator(array('test1', array('tet3', 'test4', 'test5'))); $rRegexIterator = new RegularExpression($rArrayIterator, '/^test/', RecursiveRegexIterator::ALL_MATCHES); foreach ($rRegexIterator as $key1 => $value1) { if ($rRegexIterator->hasChildren()) { // print all children echo "Children: "; foreach ($rRegexIterator->getChildren() as $key => $value) { echo $value . " "; } echo "\n"; } else { echo "No children\n"; } }
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 77) Position 1 = 11, Position 2 = 30
Branch analysis from position: 11
2 jumps found. (Code = 78) Position 1 = 12, Position 2 = 30
Branch analysis from position: 12
2 jumps found. (Code = 43) Position 1 = 16, Position 2 = 28
Branch analysis from position: 16
2 jumps found. (Code = 77) Position 1 = 20, Position 2 = 25
Branch analysis from position: 20
2 jumps found. (Code = 78) Position 1 = 21, Position 2 = 25
Branch analysis from position: 21
1 jumps found. (Code = 42) Position 1 = 20
Branch analysis from position: 20
Branch analysis from position: 25
1 jumps found. (Code = 42) Position 1 = 29
Branch analysis from position: 29
1 jumps found. (Code = 42) Position 1 = 11
Branch analysis from position: 11
Branch analysis from position: 25
Branch analysis from position: 28
1 jumps found. (Code = 42) Position 1 = 11
Branch analysis from position: 11
Branch analysis from position: 30
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 30
filename:       /in/kmfOd
function name:  (null)
number of ops:  32
compiled vars:  !0 = $rArrayIterator, !1 = $rRegexIterator, !2 = $value1, !3 = $key1, !4 = $value, !5 = $key
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   23     0  E >   NEW                                              $6      'RecursiveArrayIterator'
          1        SEND_VAL_EX                                              <array>
          2        DO_FCALL                                      0          
          3        ASSIGN                                                   !0, $6
   24     4        NEW                                              $9      'RegularExpression'
          5        SEND_VAR_EX                                              !0
          6        SEND_VAL_EX                                              '%2F%5Etest%2F'
   25     7        SEND_VAL_EX                                              2
          8        DO_FCALL                                      0          
   24     9        ASSIGN                                                   !1, $9
   27    10      > FE_RESET_R                                       $12     !1, ->30
         11    > > FE_FETCH_R                                       ~13     $12, !2, ->30
         12    >   ASSIGN                                                   !3, ~13
   29    13        INIT_METHOD_CALL                                         !1, 'hasChildren'
         14        DO_FCALL                                      0  $15     
         15      > JMPZ                                                     $15, ->28
   32    16    >   ECHO                                                     'Children%3A+'
   33    17        INIT_METHOD_CALL                                         !1, 'getChildren'
         18        DO_FCALL                                      0  $16     
         19      > FE_RESET_R                                       $17     $16, ->25
         20    > > FE_FETCH_R                                       ~18     $17, !4, ->25
         21    >   ASSIGN                                                   !5, ~18
   34    22        CONCAT                                           ~20     !4, '+'
         23        ECHO                                                     ~20
   33    24      > JMP                                                      ->20
         25    >   FE_FREE                                                  $17
   36    26        ECHO                                                     '%0A'
         27      > JMP                                                      ->29
   38    28    >   ECHO                                                     'No+children%0A'
   27    29    > > JMP                                                      ->11
         30    >   FE_FREE                                                  $12
   41    31      > RETURN                                                   1

Class RegularExpression:
Function accept:
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 47) Position 1 = 4, Position 2 = 8
Branch analysis from position: 4
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 8
filename:       /in/kmfOd
function name:  accept
number of ops:  10
compiled vars:  none
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   18     0  E >   INIT_METHOD_CALL                                         'hasChildren'
          1        DO_FCALL                                      0  $0      
          2        TYPE_CHECK                                    8  ~1      $0
          3      > JMPNZ_EX                                         ~1      ~1, ->8
   19     4    >   INIT_STATIC_METHOD_CALL                                  'accept'
          5        DO_FCALL                                      0  $2      
          6        TYPE_CHECK                                    8  ~3      $2
          7        BOOL                                             ~1      ~3
          8    > > RETURN                                                   ~1
   20     9*     > RETURN                                                   null

End of function accept

End of class RegularExpression.

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
170.5 ms | 1403 KiB | 13 Q