3v4l.org

run code in 300+ PHP versions simultaneously
<?php function getCollectionParentIDFromChildID($cID) { if(is_numeric($cID)) { if($cID > 1) { return '1'; } if($cID == 1) { return '0'; } } return null; } function populateParentIDArray_current($cID) { global $cParentIDArray; $cParentID = getCollectionParentIDFromChildID($cID); if($cParentID > -1) { if(!in_array($cParentID, $cParentIDArray)) { $cParentIDArray[] = $cParentID; } populateParentIDArray_current($cParentID); } } function populateParentIDArray_new($cID) { global $cParentIDArray; $cParentID = getCollectionParentIDFromChildID($cID); if(is_numeric($cParentID)) { if(!in_array($cParentID, $cParentIDArray)) { $cParentIDArray[] = $cParentID; } if($cParentID > 0) { populateParentIDArray_new($cParentID); } } } function runTest($cID) { global $cParentIDArray; echo "Test case for "; var_dump($cID); $cParentIDArray = array(); populateParentIDArray_current($cID); echo "CURRENT: \n"; var_dump($cParentIDArray); $cParentIDArray = array(); populateParentIDArray_new($cID); echo "CURRENT: \n"; var_dump($cParentIDArray); } runTest('3'); runTest('1'); runTest('0'); runTest(3); runTest(1); runTest(0); runTest(null); runTest('');
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/suM5J
function name:  (null)
number of ops:  25
compiled vars:  none
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   50     0  E >   INIT_FCALL                                               'runtest'
          1        SEND_VAL                                                 '3'
          2        DO_FCALL                                      0          
   51     3        INIT_FCALL                                               'runtest'
          4        SEND_VAL                                                 '1'
          5        DO_FCALL                                      0          
   52     6        INIT_FCALL                                               'runtest'
          7        SEND_VAL                                                 '0'
          8        DO_FCALL                                      0          
   53     9        INIT_FCALL                                               'runtest'
         10        SEND_VAL                                                 3
         11        DO_FCALL                                      0          
   54    12        INIT_FCALL                                               'runtest'
         13        SEND_VAL                                                 1
         14        DO_FCALL                                      0          
   55    15        INIT_FCALL                                               'runtest'
         16        SEND_VAL                                                 0
         17        DO_FCALL                                      0          
   56    18        INIT_FCALL                                               'runtest'
         19        SEND_VAL                                                 null
         20        DO_FCALL                                      0          
   57    21        INIT_FCALL                                               'runtest'
         22        SEND_VAL                                                 ''
         23        DO_FCALL                                      0          
         24      > RETURN                                                   1

Function getcollectionparentidfromchildid:
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 43) Position 1 = 5, Position 2 = 11
Branch analysis from position: 5
2 jumps found. (Code = 43) Position 1 = 7, Position 2 = 8
Branch analysis from position: 7
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 8
2 jumps found. (Code = 43) Position 1 = 10, Position 2 = 11
Branch analysis from position: 10
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 11
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 11
filename:       /in/suM5J
function name:  getCollectionParentIDFromChildID
number of ops:  13
compiled vars:  !0 = $cID
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    2     0  E >   RECV                                             !0      
    3     1        INIT_FCALL                                               'is_numeric'
          2        SEND_VAR                                                 !0
          3        DO_ICALL                                         $1      
          4      > JMPZ                                                     $1, ->11
    4     5    >   IS_SMALLER                                               1, !0
          6      > JMPZ                                                     ~2, ->8
    5     7    > > RETURN                                                   '1'
    7     8    >   IS_EQUAL                                                 !0, 1
          9      > JMPZ                                                     ~3, ->11
    8    10    > > RETURN                                                   '0'
   11    11    > > RETURN                                                   null
   12    12*     > RETURN                                                   null

End of function getcollectionparentidfromchildid

Function populateparentidarray_current:
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 43) Position 1 = 8, Position 2 = 19
Branch analysis from position: 8
2 jumps found. (Code = 43) Position 1 = 14, Position 2 = 16
Branch analysis from position: 14
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 16
Branch analysis from position: 19
filename:       /in/suM5J
function name:  populateParentIDArray_current
number of ops:  20
compiled vars:  !0 = $cID, !1 = $cParentIDArray, !2 = $cParentID
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   14     0  E >   RECV                                             !0      
   15     1        BIND_GLOBAL                                              !1, 'cParentIDArray'
   16     2        INIT_FCALL                                               'getcollectionparentidfromchildid'
          3        SEND_VAR                                                 !0
          4        DO_FCALL                                      0  $3      
          5        ASSIGN                                                   !2, $3
   17     6        IS_SMALLER                                               -1, !2
          7      > JMPZ                                                     ~5, ->19
   18     8    >   INIT_FCALL                                               'in_array'
          9        SEND_VAR                                                 !2
         10        SEND_VAR                                                 !1
         11        DO_ICALL                                         $6      
         12        BOOL_NOT                                         ~7      $6
         13      > JMPZ                                                     ~7, ->16
   19    14    >   ASSIGN_DIM                                               !1
         15        OP_DATA                                                  !2
   21    16    >   INIT_FCALL_BY_NAME                                       'populateParentIDArray_current'
         17        SEND_VAR_EX                                              !2
         18        DO_FCALL                                      0          
   23    19    > > RETURN                                                   null

End of function populateparentidarray_current

Function populateparentidarray_new:
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 43) Position 1 = 10, Position 2 = 23
Branch analysis from position: 10
2 jumps found. (Code = 43) Position 1 = 16, Position 2 = 18
Branch analysis from position: 16
2 jumps found. (Code = 43) Position 1 = 20, Position 2 = 23
Branch analysis from position: 20
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 23
Branch analysis from position: 18
Branch analysis from position: 23
filename:       /in/suM5J
function name:  populateParentIDArray_new
number of ops:  24
compiled vars:  !0 = $cID, !1 = $cParentIDArray, !2 = $cParentID
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   25     0  E >   RECV                                             !0      
   26     1        BIND_GLOBAL                                              !1, 'cParentIDArray'
   27     2        INIT_FCALL                                               'getcollectionparentidfromchildid'
          3        SEND_VAR                                                 !0
          4        DO_FCALL                                      0  $3      
          5        ASSIGN                                                   !2, $3
   28     6        INIT_FCALL                                               'is_numeric'
          7        SEND_VAR                                                 !2
          8        DO_ICALL                                         $5      
          9      > JMPZ                                                     $5, ->23
   29    10    >   INIT_FCALL                                               'in_array'
         11        SEND_VAR                                                 !2
         12        SEND_VAR                                                 !1
         13        DO_ICALL                                         $6      
         14        BOOL_NOT                                         ~7      $6
         15      > JMPZ                                                     ~7, ->18
   30    16    >   ASSIGN_DIM                                               !1
         17        OP_DATA                                                  !2
   32    18    >   IS_SMALLER                                               0, !2
         19      > JMPZ                                                     ~9, ->23
   33    20    >   INIT_FCALL_BY_NAME                                       'populateParentIDArray_new'
         21        SEND_VAR_EX                                              !2
         22        DO_FCALL                                      0          
   36    23    > > RETURN                                                   null

End of function populateparentidarray_new

Function runtest:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/suM5J
function name:  runTest
number of ops:  23
compiled vars:  !0 = $cID, !1 = $cParentIDArray
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   38     0  E >   RECV                                             !0      
   39     1        BIND_GLOBAL                                              !1, 'cParentIDArray'
   40     2        ECHO                                                     'Test+case+for+'
          3        INIT_FCALL                                               'var_dump'
          4        SEND_VAR                                                 !0
          5        DO_ICALL                                                 
   41     6        ASSIGN                                                   !1, <array>
   42     7        INIT_FCALL                                               'populateparentidarray_current'
          8        SEND_VAR                                                 !0
          9        DO_FCALL                                      0          
   43    10        ECHO                                                     'CURRENT%3A+%0A'
   44    11        INIT_FCALL                                               'var_dump'
         12        SEND_VAR                                                 !1
         13        DO_ICALL                                                 
   45    14        ASSIGN                                                   !1, <array>
   46    15        INIT_FCALL                                               'populateparentidarray_new'
         16        SEND_VAR                                                 !0
         17        DO_FCALL                                      0          
   47    18        ECHO                                                     'CURRENT%3A+%0A'
   48    19        INIT_FCALL                                               'var_dump'
         20        SEND_VAR                                                 !1
         21        DO_ICALL                                                 
   49    22      > RETURN                                                   null

End of function runtest

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
171.34 ms | 1407 KiB | 31 Q