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 = ""; $glue = "||"; echo $constructedValue = implodeMultiArr($arrVal,$glue); function implodeMultiArr($arrVal,$glue) { $i = 0; $constructedValue = ""; foreach ( $arrVal as $k=>$v) { if ( is_array($v) ) { $constructedValue .= !empty($constructedValue) ? "[".implodeMultiArr($v,$glue)."]" : implodeMultiArr($v)."]" ; } else { $constructedValue .= !empty($constructedValue) ? $glue.$v : $v ; } $i++; } return $constructedValue; }
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/lSWVA
function name:  (null)
number of ops:  10
compiled vars:  !0 = $arrVal, !1 = $constructedValue, !2 = $glue
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    2     0  E >   ASSIGN                                                   !0, <array>
   24     1        ASSIGN                                                   !1, ''
   25     2        ASSIGN                                                   !2, '%7C%7C'
   26     3        INIT_FCALL_BY_NAME                                       'implodeMultiArr'
          4        SEND_VAR_EX                                              !0
          5        SEND_VAR_EX                                              !2
          6        DO_FCALL                                      0  $6      
          7        ASSIGN                                           ~7      !1, $6
          8        ECHO                                                     ~7
   39     9      > RETURN                                                   1

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

End of function implodemultiarr

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
159.35 ms | 1399 KiB | 13 Q