3v4l.org

run code in 500+ 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 = 9
Branch analysis from position: 3
2 jumps found. (Code = 78) Position 1 = 4, Position 2 = 9
Branch analysis from position: 4
2 jumps found. (Code = 43) Position 1 = 5, Position 2 = 8
Branch analysis from position: 5
1 jumps found. (Code = 42) Position 1 = 3
Branch analysis from position: 3
Branch analysis from position: 8
Branch analysis from position: 9
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 = 62) Position 1 = -2
Branch analysis from position: 31
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 9
filename:       /in/nfEjR
function name:  (null)
number of ops:  50
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, ->9
          3    > > FE_FETCH_R                                                   $6, !2, ->9
   11     4    > > JMPZ                                                         !2, ->8
   12     5    >   FRAMELESS_ICALL_2                implode             ~8      '%2C', !2
          6        ASSIGN_DIM                                                   !1
          7        OP_DATA                                                      ~8
   10     8    > > JMP                                                          ->3
          9    >   FE_FREE                                                      $6
   15    10        FRAMELESS_ICALL_2                implode             ~9      '%2C', !1
         11        ECHO                                                         ~9
   17    12        ECHO                                                         '%0A%0A---%0A%0A'
   19    13        INIT_FCALL                                                   'array_walk_recursive'
   20    14        SEND_REF                                                     !0
   21    15        DECLARE_LAMBDA_FUNCTION                              ~10     [0]
   25    16        SEND_VAL                                                     ~10
   19    17        DO_ICALL                                                     
   28    18        ECHO                                                         '%0A%0A---%0A%0A'
   32    19        INIT_FCALL                                                   'preg_match_all'
   33    20        SEND_VAL                                                     '%2F%5Ba-z%5D%5Cd%2B%2F'
   34    21        INIT_FCALL                                                   'json_encode'
         22        SEND_VAR                                                     !0
         23        DO_ICALL                                             $12     
         24        SEND_VAR                                                     $12
   35    25        SEND_REF                                                     !3
   32    26        DO_ICALL                                             $13     
   35    27      > JMPZ                                                         $13, ->31
   37    28    >   FETCH_DIM_R                                          ~14     !3, 0
         29        QM_ASSIGN                                            ~15     ~14
         30      > JMP                                                          ->32
   38    31    >   QM_ASSIGN                                            ~15     <array>
   30    32    >   FRAMELESS_ICALL_2                implode             ~16     '%2C', ~15
   38    33        ECHO                                                         ~16
   41    34        ECHO                                                         '%0A%0A---%0A%0A'
   45    35        INIT_FCALL                                                   'preg_split'
   46    36        SEND_VAL                                                     '%2F%5CW%2B%2F'
   47    37        INIT_FCALL                                                   'json_encode'
         38        INIT_FCALL                                                   'array_values'
         39        SEND_VAR                                                     !0
         40        DO_ICALL                                             $17     
         41        SEND_VAR                                                     $17
         42        DO_ICALL                                             $18     
         43        SEND_VAR                                                     $18
   48    44        SEND_VAL                                                     0
   49    45        SEND_VAL                                                     1
   45    46        DO_ICALL                                             $19     
   43    47        FRAMELESS_ICALL_2                implode             ~20     '%2C', $19
   49    48        ECHO                                                         ~20
   51    49      > 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:/in/nfEjR:21}
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.5.0


preferences:
175.75 ms | 1889 KiB | 18 Q