3v4l.org

run code in 300+ PHP versions simultaneously
<?php class Recursion { public static function recursionLevelOne($information, $keylist) { $global_array = array(); $keys = explode($keylist, ","); foreach($keys as $individual_key) $global_array = self::recursionLevelTwo($information, $individual_key); return $global_array; } private static function recursionLevelTwo($array, $key) { if(count($array) == 0) return; $global_array = array(); foreach($array as $k => $v) { if($k == $key) if($array[$k] != self::$asterisk) $array[$k] = self::$asterisk; else { if(is_array($v)) { $temp_array = self::recursionLevelTwo($v, $key); array_push($global_array, $temp_array); } } } return $global_array; } private static $asterisk = "**"; } $information = array("login" => "someUsername", "password" => "somePassword", "card_pin"=>"card_1234", "pin"=>"pin_356", "iin" => "iin_123", "shipping" => array("telephone" => "telephone_998"), "cardnumber" => "card_number_876", "customer_id" => "customer_654", "telephone" => "someOtherTelephoneNumber555"); $list = "login,customer_id"; print_r($information); echo PHP.EOL; echo PHP.EOL; $global_array = Recursion::recursionLevelOne($information, $list); print_r($global_array);
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/RLUaq
function name:  (null)
number of ops:  22
compiled vars:  !0 = $information, !1 = $list, !2 = $global_array
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   45     0  E >   ASSIGN                                                   !0, <array>
   54     1        ASSIGN                                                   !1, 'login%2Ccustomer_id'
   56     2        INIT_FCALL                                               'print_r'
          3        SEND_VAR                                                 !0
          4        DO_ICALL                                                 
   57     5        FETCH_CONSTANT                                   ~6      'PHP'
          6        FETCH_CONSTANT                                   ~7      'EOL'
          7        CONCAT                                           ~8      ~6, ~7
          8        ECHO                                                     ~8
   58     9        FETCH_CONSTANT                                   ~9      'PHP'
         10        FETCH_CONSTANT                                   ~10     'EOL'
         11        CONCAT                                           ~11     ~9, ~10
         12        ECHO                                                     ~11
   60    13        INIT_STATIC_METHOD_CALL                                  'Recursion', 'recursionLevelOne'
         14        SEND_VAR                                                 !0
         15        SEND_VAR                                                 !1
         16        DO_FCALL                                      0  $12     
         17        ASSIGN                                                   !2, $12
   62    18        INIT_FCALL                                               'print_r'
         19        SEND_VAR                                                 !2
         20        DO_ICALL                                                 
         21      > RETURN                                                   1

Class Recursion:
Function recursionlevelone:
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 77) Position 1 = 9, Position 2 = 16
Branch analysis from position: 9
2 jumps found. (Code = 78) Position 1 = 10, Position 2 = 16
Branch analysis from position: 10
1 jumps found. (Code = 42) Position 1 = 9
Branch analysis from position: 9
Branch analysis from position: 16
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 16
filename:       /in/RLUaq
function name:  recursionLevelOne
number of ops:  19
compiled vars:  !0 = $information, !1 = $keylist, !2 = $global_array, !3 = $keys, !4 = $individual_key
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    5     0  E >   RECV                                             !0      
          1        RECV                                             !1      
    7     2        ASSIGN                                                   !2, <array>
    8     3        INIT_FCALL                                               'explode'
          4        SEND_VAR                                                 !1
          5        SEND_VAL                                                 '%2C'
          6        DO_ICALL                                         $6      
          7        ASSIGN                                                   !3, $6
   10     8      > FE_RESET_R                                       $8      !3, ->16
          9    > > FE_FETCH_R                                               $8, !4, ->16
   11    10    >   INIT_STATIC_METHOD_CALL                                  'recursionLevelTwo'
         11        SEND_VAR_EX                                              !0
         12        SEND_VAR_EX                                              !4
         13        DO_FCALL                                      0  $9      
         14        ASSIGN                                                   !2, $9
   10    15      > JMP                                                      ->9
         16    >   FE_FREE                                                  $8
   13    17      > RETURN                                                   !2
   14    18*     > RETURN                                                   null

End of function recursionlevelone

Function recursionleveltwo:
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 43) Position 1 = 5, Position 2 = 6
Branch analysis from position: 5
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 6
2 jumps found. (Code = 77) Position 1 = 8, Position 2 = 32
Branch analysis from position: 8
2 jumps found. (Code = 78) Position 1 = 9, Position 2 = 32
Branch analysis from position: 9
2 jumps found. (Code = 43) Position 1 = 12, Position 2 = 31
Branch analysis from position: 12
2 jumps found. (Code = 43) Position 1 = 16, Position 2 = 20
Branch analysis from position: 16
1 jumps found. (Code = 42) Position 1 = 31
Branch analysis from position: 31
1 jumps found. (Code = 42) Position 1 = 8
Branch analysis from position: 8
Branch analysis from position: 20
2 jumps found. (Code = 43) Position 1 = 22, Position 2 = 31
Branch analysis from position: 22
1 jumps found. (Code = 42) Position 1 = 8
Branch analysis from position: 8
Branch analysis from position: 31
Branch analysis from position: 31
Branch analysis from position: 32
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 32
filename:       /in/RLUaq
function name:  recursionLevelTwo
number of ops:  35
compiled vars:  !0 = $array, !1 = $key, !2 = $global_array, !3 = $v, !4 = $k, !5 = $temp_array
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   16     0  E >   RECV                                             !0      
          1        RECV                                             !1      
   18     2        COUNT                                            ~6      !0
          3        IS_EQUAL                                                 ~6, 0
          4      > JMPZ                                                     ~7, ->6
   19     5    > > RETURN                                                   null
   21     6    >   ASSIGN                                                   !2, <array>
   23     7      > FE_RESET_R                                       $9      !0, ->32
          8    > > FE_FETCH_R                                       ~10     $9, !3, ->32
          9    >   ASSIGN                                                   !4, ~10
   25    10        IS_EQUAL                                                 !4, !1
         11      > JMPZ                                                     ~12, ->31
   26    12    >   FETCH_DIM_R                                      ~13     !0, !4
         13        FETCH_STATIC_PROP_R          unknown             ~14     'asterisk'
         14        IS_NOT_EQUAL                                             ~13, ~14
         15      > JMPZ                                                     ~15, ->20
   27    16    >   FETCH_STATIC_PROP_R          unknown             ~17     'asterisk'
         17        ASSIGN_DIM                                               !0, !4
         18        OP_DATA                                                  ~17
         19      > JMP                                                      ->31
   31    20    >   TYPE_CHECK                                  128          !3
         21      > JMPZ                                                     ~18, ->31
   33    22    >   INIT_STATIC_METHOD_CALL                                  'recursionLevelTwo'
         23        SEND_VAR                                                 !3
         24        SEND_VAR                                                 !1
         25        DO_FCALL                                      0  $19     
         26        ASSIGN                                                   !5, $19
   34    27        INIT_FCALL                                               'array_push'
         28        SEND_REF                                                 !2
         29        SEND_VAR                                                 !5
         30        DO_ICALL                                                 
   23    31    > > JMP                                                      ->8
         32    >   FE_FREE                                                  $9
   39    33      > RETURN                                                   !2
   40    34*     > RETURN                                                   null

End of function recursionleveltwo

End of class Recursion.

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
165.1 ms | 1408 KiB | 19 Q