3v4l.org

run code in 300+ PHP versions simultaneously
<?php $path = ""; $finalArray = array(); $sourceArray = array( "bla.tif", "quux.tif", array("foo" => array("bar" => array("lorem" => array("ipsum.tif", "doler.tif")))), array("bar" => array("qux" => array("baz" => array("ipsum.tif", "ufo.tif")))) ); foreach($sourceArray as $key => $value) { if(!is_array($value)) { $finalArray[] = $value; } else { $finalArray[] = recur($value, $path); } } print_r($finalArray); function recur($value, $path) { foreach($value as $idx => $subValue) { if(!is_array($subValue)) { return $path . "/" . $subValue; } else { return recur($subValue, $path); } } }
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 77) Position 1 = 4, Position 2 = 19
Branch analysis from position: 4
2 jumps found. (Code = 78) Position 1 = 5, Position 2 = 19
Branch analysis from position: 5
2 jumps found. (Code = 43) Position 1 = 9, Position 2 = 12
Branch analysis from position: 9
1 jumps found. (Code = 42) Position 1 = 18
Branch analysis from position: 18
1 jumps found. (Code = 42) Position 1 = 4
Branch analysis from position: 4
Branch analysis from position: 12
1 jumps found. (Code = 42) Position 1 = 4
Branch analysis from position: 4
Branch analysis from position: 19
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 19
filename:       /in/obkgJ
function name:  (null)
number of ops:  24
compiled vars:  !0 = $path, !1 = $finalArray, !2 = $sourceArray, !3 = $value, !4 = $key
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    3     0  E >   ASSIGN                                                   !0, ''
    4     1        ASSIGN                                                   !1, <array>
    6     2        ASSIGN                                                   !2, <array>
   14     3      > FE_RESET_R                                       $8      !2, ->19
          4    > > FE_FETCH_R                                       ~9      $8, !3, ->19
          5    >   ASSIGN                                                   !4, ~9
   16     6        TYPE_CHECK                                  128  ~11     !3
          7        BOOL_NOT                                         ~12     ~11
          8      > JMPZ                                                     ~12, ->12
   18     9    >   ASSIGN_DIM                                               !1
         10        OP_DATA                                                  !3
         11      > JMP                                                      ->18
   22    12    >   INIT_FCALL_BY_NAME                                       'recur'
         13        SEND_VAR_EX                                              !3
         14        SEND_VAR_EX                                              !0
         15        DO_FCALL                                      0  $15     
         16        ASSIGN_DIM                                               !1
         17        OP_DATA                                                  $15
   14    18    > > JMP                                                      ->4
         19    >   FE_FREE                                                  $8
   26    20        INIT_FCALL                                               'print_r'
         21        SEND_VAR                                                 !1
         22        DO_ICALL                                                 
   41    23      > RETURN                                                   1

Function recur:
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 77) Position 1 = 3, Position 2 = 20
Branch analysis from position: 3
2 jumps found. (Code = 78) Position 1 = 4, Position 2 = 20
Branch analysis from position: 4
2 jumps found. (Code = 43) Position 1 = 8, Position 2 = 13
Branch analysis from position: 8
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 13
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 20
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 20
filename:       /in/obkgJ
function name:  recur
number of ops:  22
compiled vars:  !0 = $value, !1 = $path, !2 = $subValue, !3 = $idx
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   28     0  E >   RECV                                             !0      
          1        RECV                                             !1      
   30     2      > FE_RESET_R                                       $4      !0, ->20
          3    > > FE_FETCH_R                                       ~5      $4, !2, ->20
          4    >   ASSIGN                                                   !3, ~5
   32     5        TYPE_CHECK                                  128  ~7      !2
          6        BOOL_NOT                                         ~8      ~7
          7      > JMPZ                                                     ~8, ->13
   34     8    >   CONCAT                                           ~9      !1, '%2F'
          9        CONCAT                                           ~10     ~9, !2
         10        FE_FREE                                                  $4
         11      > RETURN                                                   ~10
         12*       JMP                                                      ->19
   38    13    >   INIT_FCALL_BY_NAME                                       'recur'
         14        SEND_VAR_EX                                              !2
         15        SEND_VAR_EX                                              !1
         16        DO_FCALL                                      0  $11     
         17        FE_FREE                                                  $4
         18      > RETURN                                                   $11
   30    19*       JMP                                                      ->3
         20    >   FE_FREE                                                  $4
   41    21      > RETURN                                                   null

End of function recur

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
147.23 ms | 1400 KiB | 15 Q