3v4l.org

run code in 300+ PHP versions simultaneously
<?php $labels = array('Element1', 'Element2', 'Element3', 'Element4', 'Element5', 'Element6'); # Put them into pairs $pairs_array = array_chunk($labels, 2); # Use array_map with custom function function joinTwoStrings($one_pair) { return $one_pair[0] . ', ' . $one_pair[1]; } $pairs_array = array_map('joinTwoStrings', $pairs_array); echo implode(',' . PHP_EOL, $pairs_array);
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/Fcvf8
function name:  (null)
number of ops:  17
compiled vars:  !0 = $labels, !1 = $pairs_array
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    2     0  E >   ASSIGN                                                   !0, <array>
    5     1        INIT_FCALL                                               'array_chunk'
          2        SEND_VAR                                                 !0
          3        SEND_VAL                                                 2
          4        DO_ICALL                                         $3      
          5        ASSIGN                                                   !1, $3
   12     6        INIT_FCALL                                               'array_map'
          7        SEND_VAL                                                 'joinTwoStrings'
          8        SEND_VAR                                                 !1
          9        DO_ICALL                                         $5      
         10        ASSIGN                                                   !1, $5
   14    11        INIT_FCALL                                               'implode'
         12        SEND_VAL                                                 '%2C%0A'
         13        SEND_VAR                                                 !1
         14        DO_ICALL                                         $7      
         15        ECHO                                                     $7
         16      > RETURN                                                   1

Function jointwostrings:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/Fcvf8
function name:  joinTwoStrings
number of ops:  7
compiled vars:  !0 = $one_pair
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    8     0  E >   RECV                                             !0      
    9     1        FETCH_DIM_R                                      ~1      !0, 0
          2        CONCAT                                           ~2      ~1, '%2C+'
          3        FETCH_DIM_R                                      ~3      !0, 1
          4        CONCAT                                           ~4      ~2, ~3
          5      > RETURN                                                   ~4
   10     6*     > RETURN                                                   null

End of function jointwostrings

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
145.13 ms | 1395 KiB | 19 Q