3v4l.org

run code in 300+ PHP versions simultaneously
<?php $arrVal = array ( '22' => array( '0' => 60, '29' => array( '0' => 6 ), '30' => array ( '0' => 5, '1' => 8 ), '31' => array ( '0' => 7, '1' => 9, '2' => 14, '3' => 26 ) ), '23' => 12, '35' => 10, '42' => 22 ); //60[6][5||8][7||9||14||26]|12|10|22 $constructedValue = ""; echo $constructedValue = implodeMultiArr($arrVal); function implodeMultiArr($arrVal) { $i = 0; $constructedValue = ""; foreach ( $arrVal as $k=>$v) { if ( is_array($v) ) { $constructedValue .= !empty($constructedValue) ? "[".implodeMultiArr($v)."]" : implodeMultiArr($v)."]" ; } else { $constructedValue .= !empty($constructedValue) ? "||".$v : $v ; } $i++; } return $constructedValue; }
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/eqHmq
function name:  (null)
number of ops:  8
compiled vars:  !0 = $arrVal, !1 = $constructedValue
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    2     0  E >   ASSIGN                                                   !0, <array>
   24     1        ASSIGN                                                   !1, ''
   25     2        INIT_FCALL_BY_NAME                                       'implodeMultiArr'
          3        SEND_VAR_EX                                              !0
          4        DO_FCALL                                      0  $4      
          5        ASSIGN                                           ~5      !1, $4
          6        ECHO                                                     ~5
   38     7      > RETURN                                                   1

Function implodemultiarr:
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 77) Position 1 = 4, Position 2 = 35
Branch analysis from position: 4
2 jumps found. (Code = 78) Position 1 = 5, Position 2 = 35
Branch analysis from position: 5
2 jumps found. (Code = 43) Position 1 = 8, Position 2 = 25
Branch analysis from position: 8
2 jumps found. (Code = 43) Position 1 = 11, Position 2 = 18
Branch analysis from position: 11
1 jumps found. (Code = 42) Position 1 = 23
Branch analysis from position: 23
1 jumps found. (Code = 42) Position 1 = 33
Branch analysis from position: 33
1 jumps found. (Code = 42) Position 1 = 4
Branch analysis from position: 4
Branch analysis from position: 18
1 jumps found. (Code = 42) Position 1 = 33
Branch analysis from position: 33
Branch analysis from position: 25
2 jumps found. (Code = 43) Position 1 = 28, Position 2 = 31
Branch analysis from position: 28
1 jumps found. (Code = 42) Position 1 = 32
Branch analysis from position: 32
1 jumps found. (Code = 42) Position 1 = 4
Branch analysis from position: 4
Branch analysis from position: 31
1 jumps found. (Code = 42) Position 1 = 4
Branch analysis from position: 4
Branch analysis from position: 35
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 35
filename:       /in/eqHmq
function name:  implodeMultiArr
number of ops:  38
compiled vars:  !0 = $arrVal, !1 = $i, !2 = $constructedValue, !3 = $v, !4 = $k
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   26     0  E >   RECV                                             !0      
   27     1        ASSIGN                                                   !1, 0
   28     2        ASSIGN                                                   !2, ''
   29     3      > FE_RESET_R                                       $7      !0, ->35
          4    > > FE_FETCH_R                                       ~8      $7, !3, ->35
          5    >   ASSIGN                                                   !4, ~8
   30     6        TYPE_CHECK                                  128          !3
          7      > JMPZ                                                     ~10, ->25
   31     8    >   ISSET_ISEMPTY_CV                                 ~11     !2
          9        BOOL_NOT                                         ~12     ~11
         10      > JMPZ                                                     ~12, ->18
         11    >   INIT_FCALL_BY_NAME                                       'implodeMultiArr'
         12        SEND_VAR_EX                                              !3
         13        DO_FCALL                                      0  $13     
         14        CONCAT                                           ~14     '%5B', $13
         15        CONCAT                                           ~15     ~14, '%5D'
         16        QM_ASSIGN                                        ~16     ~15
         17      > JMP                                                      ->23
         18    >   INIT_FCALL_BY_NAME                                       'implodeMultiArr'
         19        SEND_VAR_EX                                              !3
         20        DO_FCALL                                      0  $17     
         21        CONCAT                                           ~18     $17, '%5D'
         22        QM_ASSIGN                                        ~16     ~18
         23    >   ASSIGN_OP                                     8          !2, ~16
         24      > JMP                                                      ->33
   33    25    >   ISSET_ISEMPTY_CV                                 ~20     !2
         26        BOOL_NOT                                         ~21     ~20
         27      > JMPZ                                                     ~21, ->31
         28    >   CONCAT                                           ~22     '%7C%7C', !3
         29        QM_ASSIGN                                        ~23     ~22
         30      > JMP                                                      ->32
         31    >   QM_ASSIGN                                        ~23     !3
         32    >   ASSIGN_OP                                     8          !2, ~23
   35    33    >   PRE_INC                                                  !1
   29    34      > JMP                                                      ->4
         35    >   FE_FREE                                                  $7
   37    36      > RETURN                                                   !2
   38    37*     > RETURN                                                   null

End of function implodemultiarr

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
159.14 ms | 1399 KiB | 13 Q