3v4l.org

run code in 300+ PHP versions simultaneously
<?php $wbs = '.002.001.005'; function getParentActionID($wbs){ $pieces = explode(".", $wbs); $resultat = array(); for($i = 1; $i < count($pieces)-1; $i++){ $invID = str_pad($pieces[$i], 3, '0', STR_PAD_LEFT); $newstr = substr_replace($invID, ".", 0, 0); array_push($resultat, $newstr); } $newRes = implode("", $resultat); return $newRes; } echo "Parent ID : "; var_dump(getParentActionID($wbs)); echo "</br>"; function getPreviousSiblingID($wbs){ $pieces = explode(".", $wbs); $resultat = array(); $invID = end($pieces) - 1; $wbsPrevious = substr_replace(str_pad($invID, 3, '0', STR_PAD_LEFT), ".", 0, 0); for($i = 1; $i < count($pieces)-1; $i++){ $invID = str_pad($pieces[$i], 3, '0', STR_PAD_LEFT); $newstr = substr_replace($invID, ".", 0, 0); array_push($resultat, $newstr); } array_push($resultat, $wbsPrevious); $newRes = implode("", $resultat); return $newRes; } echo "Previous Sibling ID : "; var_dump(getPreviousSiblingID($wbs)); echo "</br>";
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/lXmsj
function name:  (null)
number of ops:  18
compiled vars:  !0 = $wbs
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    2     0  E >   ASSIGN                                                   !0, '.002.001.005'
   23     1        ECHO                                                     'Parent+ID+%3A++'
   24     2        INIT_FCALL                                               'var_dump'
          3        INIT_FCALL                                               'getparentactionid'
          4        SEND_VAR                                                 !0
          5        DO_FCALL                                      0  $2      
          6        SEND_VAR                                                 $2
          7        DO_ICALL                                                 
   25     8        ECHO                                                     '%3C%2Fbr%3E'
   48     9        ECHO                                                     'Previous+Sibling+ID+%3A++'
   49    10        INIT_FCALL                                               'var_dump'
         11        INIT_FCALL                                               'getprevioussiblingid'
         12        SEND_VAR                                                 !0
         13        DO_FCALL                                      0  $4      
         14        SEND_VAR                                                 $4
         15        DO_ICALL                                                 
   50    16        ECHO                                                     '%3C%2Fbr%3E'
         17      > RETURN                                                   1

Function getparentactionid:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 42) Position 1 = 29
Branch analysis from position: 29
2 jumps found. (Code = 44) Position 1 = 33, Position 2 = 9
Branch analysis from position: 33
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 9
2 jumps found. (Code = 44) Position 1 = 33, Position 2 = 9
Branch analysis from position: 33
Branch analysis from position: 9
filename:       /in/lXmsj
function name:  getParentActionID
number of ops:  40
compiled vars:  !0 = $wbs, !1 = $pieces, !2 = $resultat, !3 = $i, !4 = $invID, !5 = $newstr, !6 = $newRes
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   10     0  E >   RECV                                             !0      
   11     1        INIT_FCALL                                               'explode'
          2        SEND_VAL                                                 '.'
          3        SEND_VAR                                                 !0
          4        DO_ICALL                                         $7      
          5        ASSIGN                                                   !1, $7
   12     6        ASSIGN                                                   !2, <array>
   13     7        ASSIGN                                                   !3, 1
          8      > JMP                                                      ->29
   14     9    >   INIT_FCALL                                               'str_pad'
         10        FETCH_DIM_R                                      ~11     !1, !3
         11        SEND_VAL                                                 ~11
         12        SEND_VAL                                                 3
         13        SEND_VAL                                                 '0'
         14        SEND_VAL                                                 0
         15        DO_ICALL                                         $12     
         16        ASSIGN                                                   !4, $12
   15    17        INIT_FCALL                                               'substr_replace'
         18        SEND_VAR                                                 !4
         19        SEND_VAL                                                 '.'
         20        SEND_VAL                                                 0
         21        SEND_VAL                                                 0
         22        DO_ICALL                                         $14     
         23        ASSIGN                                                   !5, $14
   16    24        INIT_FCALL                                               'array_push'
         25        SEND_REF                                                 !2
         26        SEND_VAR                                                 !5
         27        DO_ICALL                                                 
   13    28        PRE_INC                                                  !3
         29    >   COUNT                                            ~18     !1
         30        SUB                                              ~19     ~18, 1
         31        IS_SMALLER                                               !3, ~19
         32      > JMPNZ                                                    ~20, ->9
   18    33    >   INIT_FCALL                                               'implode'
         34        SEND_VAL                                                 ''
         35        SEND_VAR                                                 !2
         36        DO_ICALL                                         $21     
         37        ASSIGN                                                   !6, $21
   20    38      > RETURN                                                   !6
   21    39*     > RETURN                                                   null

End of function getparentactionid

Function getprevioussiblingid:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 42) Position 1 = 47
Branch analysis from position: 47
2 jumps found. (Code = 44) Position 1 = 51, Position 2 = 27
Branch analysis from position: 51
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 27
2 jumps found. (Code = 44) Position 1 = 51, Position 2 = 27
Branch analysis from position: 51
Branch analysis from position: 27
filename:       /in/lXmsj
function name:  getPreviousSiblingID
number of ops:  62
compiled vars:  !0 = $wbs, !1 = $pieces, !2 = $resultat, !3 = $invID, !4 = $wbsPrevious, !5 = $i, !6 = $newstr, !7 = $newRes
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   32     0  E >   RECV                                             !0      
   33     1        INIT_FCALL                                               'explode'
          2        SEND_VAL                                                 '.'
          3        SEND_VAR                                                 !0
          4        DO_ICALL                                         $8      
          5        ASSIGN                                                   !1, $8
   34     6        ASSIGN                                                   !2, <array>
   35     7        INIT_FCALL                                               'end'
          8        SEND_REF                                                 !1
          9        DO_ICALL                                         $11     
         10        SUB                                              ~12     $11, 1
         11        ASSIGN                                                   !3, ~12
   36    12        INIT_FCALL                                               'substr_replace'
         13        INIT_FCALL                                               'str_pad'
         14        SEND_VAR                                                 !3
         15        SEND_VAL                                                 3
         16        SEND_VAL                                                 '0'
         17        SEND_VAL                                                 0
         18        DO_ICALL                                         $14     
         19        SEND_VAR                                                 $14
         20        SEND_VAL                                                 '.'
         21        SEND_VAL                                                 0
         22        SEND_VAL                                                 0
         23        DO_ICALL                                         $15     
         24        ASSIGN                                                   !4, $15
   37    25        ASSIGN                                                   !5, 1
         26      > JMP                                                      ->47
   38    27    >   INIT_FCALL                                               'str_pad'
         28        FETCH_DIM_R                                      ~18     !1, !5
         29        SEND_VAL                                                 ~18
         30        SEND_VAL                                                 3
         31        SEND_VAL                                                 '0'
         32        SEND_VAL                                                 0
         33        DO_ICALL                                         $19     
         34        ASSIGN                                                   !3, $19
   39    35        INIT_FCALL                                               'substr_replace'
         36        SEND_VAR                                                 !3
         37        SEND_VAL                                                 '.'
         38        SEND_VAL                                                 0
         39        SEND_VAL                                                 0
         40        DO_ICALL                                         $21     
         41        ASSIGN                                                   !6, $21
   40    42        INIT_FCALL                                               'array_push'
         43        SEND_REF                                                 !2
         44        SEND_VAR                                                 !6
         45        DO_ICALL                                                 
   37    46        PRE_INC                                                  !5
         47    >   COUNT                                            ~25     !1
         48        SUB                                              ~26     ~25, 1
         49        IS_SMALLER                                               !5, ~26
         50      > JMPNZ                                                    ~27, ->27
   42    51    >   INIT_FCALL                                               'array_push'
         52        SEND_REF                                                 !2
         53        SEND_VAR                                                 !4
         54        DO_ICALL                                                 
   43    55        INIT_FCALL                                               'implode'
         56        SEND_VAL                                                 ''
         57        SEND_VAR                                                 !2
         58        DO_ICALL                                         $29     
         59        ASSIGN                                                   !7, $29
   45    60      > RETURN                                                   !7
   46    61*     > RETURN                                                   null

End of function getprevioussiblingid

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
165.17 ms | 1407 KiB | 29 Q