3v4l.org

run code in 300+ PHP versions simultaneously
<?php $array = [ ['s1','s2','s5','s1','s25','s1','s6','s6','s1'], 2 => ['a2','a1','a4'], [], [] ]; $result = []; foreach ($array as $subarray) { if ($subarray) { $result[] = implode(',', $subarray); } } echo implode(',', $result); echo "\n\n---\n\n"; array_walk_recursive( $array, function($v) { static $first; echo $first . $v; $first = ','; } ); echo "\n\n---\n\n"; echo implode( ',', preg_match_all( '/[a-z]\d+/', json_encode($array), $out ) ? $out[0] : [] ); echo "\n\n---\n\n"; echo implode( ',', preg_split( '/\W+/', json_encode(array_values($array)), 0, PREG_SPLIT_NO_EMPTY ) );
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 77) Position 1 = 3, Position 2 = 12
Branch analysis from position: 3
2 jumps found. (Code = 78) Position 1 = 4, Position 2 = 12
Branch analysis from position: 4
2 jumps found. (Code = 43) Position 1 = 5, Position 2 = 11
Branch analysis from position: 5
1 jumps found. (Code = 42) Position 1 = 3
Branch analysis from position: 3
Branch analysis from position: 11
Branch analysis from position: 12
2 jumps found. (Code = 43) Position 1 = 36, Position 2 = 39
Branch analysis from position: 36
1 jumps found. (Code = 42) Position 1 = 40
Branch analysis from position: 40
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 39
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 12
filename:       /in/nfEjR
function name:  (null)
number of ops:  62
compiled vars:  !0 = $array, !1 = $result, !2 = $subarray, !3 = $out
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    3     0  E >   ASSIGN                                                   !0, <array>
    9     1        ASSIGN                                                   !1, <array>
   10     2      > FE_RESET_R                                       $6      !0, ->12
          3    > > FE_FETCH_R                                               $6, !2, ->12
   11     4    > > JMPZ                                                     !2, ->11
   12     5    >   INIT_FCALL                                               'implode'
          6        SEND_VAL                                                 '%2C'
          7        SEND_VAR                                                 !2
          8        DO_ICALL                                         $8      
          9        ASSIGN_DIM                                               !1
         10        OP_DATA                                                  $8
   10    11    > > JMP                                                      ->3
         12    >   FE_FREE                                                  $6
   15    13        INIT_FCALL                                               'implode'
         14        SEND_VAL                                                 '%2C'
         15        SEND_VAR                                                 !1
         16        DO_ICALL                                         $9      
         17        ECHO                                                     $9
   17    18        ECHO                                                     '%0A%0A---%0A%0A'
   19    19        INIT_FCALL                                               'array_walk_recursive'
   20    20        SEND_REF                                                 !0
   21    21        DECLARE_LAMBDA_FUNCTION                          ~10     [0]
   25    22        SEND_VAL                                                 ~10
   19    23        DO_ICALL                                                 
   28    24        ECHO                                                     '%0A%0A---%0A%0A'
   30    25        INIT_FCALL                                               'implode'
   31    26        SEND_VAL                                                 '%2C'
   32    27        INIT_FCALL                                               'preg_match_all'
   33    28        SEND_VAL                                                 '%2F%5Ba-z%5D%5Cd%2B%2F'
   34    29        INIT_FCALL                                               'json_encode'
         30        SEND_VAR                                                 !0
         31        DO_ICALL                                         $12     
         32        SEND_VAR                                                 $12
   35    33        SEND_REF                                                 !3
   32    34        DO_ICALL                                         $13     
   35    35      > JMPZ                                                     $13, ->39
   37    36    >   FETCH_DIM_R                                      ~14     !3, 0
         37        QM_ASSIGN                                        ~15     ~14
         38      > JMP                                                      ->40
   38    39    >   QM_ASSIGN                                        ~15     <array>
         40    >   SEND_VAL                                                 ~15
   30    41        DO_ICALL                                         $16     
   38    42        ECHO                                                     $16
   41    43        ECHO                                                     '%0A%0A---%0A%0A'
   43    44        INIT_FCALL                                               'implode'
   44    45        SEND_VAL                                                 '%2C'
   45    46        INIT_FCALL                                               'preg_split'
   46    47        SEND_VAL                                                 '%2F%5CW%2B%2F'
   47    48        INIT_FCALL                                               'json_encode'
         49        INIT_FCALL                                               'array_values'
         50        SEND_VAR                                                 !0
         51        DO_ICALL                                         $17     
         52        SEND_VAR                                                 $17
         53        DO_ICALL                                         $18     
         54        SEND_VAR                                                 $18
   48    55        SEND_VAL                                                 0
   49    56        SEND_VAL                                                 1
   45    57        DO_ICALL                                         $19     
   49    58        SEND_VAR                                                 $19
   43    59        DO_ICALL                                         $20     
   49    60        ECHO                                                     $20
   51    61      > RETURN                                                   1


Dynamic Functions:
Dynamic Function 0
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/nfEjR
function name:  {closure}
number of ops:  6
compiled vars:  !0 = $v, !1 = $first
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   21     0  E >   RECV                                             !0      
   22     1        BIND_STATIC                                              !1
   23     2        CONCAT                                           ~2      !1, !0
          3        ECHO                                                     ~2
   24     4        ASSIGN                                                   !1, '%2C'
   25     5      > RETURN                                                   null

End of Dynamic Function 0

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
160.02 ms | 1021 KiB | 19 Q