3v4l.org

run code in 500+ PHP versions simultaneously
<?php $arrays[] = array(); $arrays[] = array('user1'); $arrays[] = array('user1', 'user2'); $arrays[] = array('user1', 'user2', 'user3'); $arrays[] = array('user1', 'user2', 'user3', 'user4'); $arrays[] = array('user1', 'user2', 'user3', 'user4', 'user5'); foreach ($arrays as $i => $array) { echo "TEST $i: "; $count = sizeof($array); if ($count < 3) { echo implode(' and ', $array); } else { if ($count == 3) { $array[2] = "and {$array[2]}"; } elseif ($count > 3) { $more = $count - 3; array_splice($array, 3, $more, ["and $more other" . ($more > 1 ? 's' : '')]); } echo implode(', ', $array); } echo "\n---\n"; }
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 77) Position 1 = 13, Position 2 = 58
Branch analysis from position: 13
2 jumps found. (Code = 78) Position 1 = 14, Position 2 = 58
Branch analysis from position: 14
2 jumps found. (Code = 43) Position 1 = 23, Position 2 = 26
Branch analysis from position: 23
1 jumps found. (Code = 42) Position 1 = 56
Branch analysis from position: 56
1 jumps found. (Code = 42) Position 1 = 13
Branch analysis from position: 13
Branch analysis from position: 26
2 jumps found. (Code = 43) Position 1 = 28, Position 2 = 34
Branch analysis from position: 28
1 jumps found. (Code = 42) Position 1 = 54
Branch analysis from position: 54
1 jumps found. (Code = 42) Position 1 = 13
Branch analysis from position: 13
Branch analysis from position: 34
2 jumps found. (Code = 43) Position 1 = 36, Position 2 = 54
Branch analysis from position: 36
2 jumps found. (Code = 43) Position 1 = 47, Position 2 = 49
Branch analysis from position: 47
1 jumps found. (Code = 42) Position 1 = 50
Branch analysis from position: 50
1 jumps found. (Code = 42) Position 1 = 13
Branch analysis from position: 13
Branch analysis from position: 49
1 jumps found. (Code = 42) Position 1 = 13
Branch analysis from position: 13
Branch analysis from position: 54
Branch analysis from position: 58
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 58
filename:       /in/P2Keg
function name:  (null)
number of ops:  60
compiled vars:  !0 = $arrays, !1 = $array, !2 = $i, !3 = $count, !4 = $more
line      #* E I O op                               fetch          ext  return  operands
-----------------------------------------------------------------------------------------
    2     0  E >   ASSIGN_DIM                                                   !0
          1        OP_DATA                                                      <array>
    3     2        ASSIGN_DIM                                                   !0
          3        OP_DATA                                                      <array>
    4     4        ASSIGN_DIM                                                   !0
          5        OP_DATA                                                      <array>
    5     6        ASSIGN_DIM                                                   !0
          7        OP_DATA                                                      <array>
    6     8        ASSIGN_DIM                                                   !0
          9        OP_DATA                                                      <array>
    7    10        ASSIGN_DIM                                                   !0
         11        OP_DATA                                                      <array>
    9    12      > FE_RESET_R                                           $11     !0, ->58
         13    > > FE_FETCH_R                                           ~12     $11, !1, ->58
         14    >   ASSIGN                                                       !2, ~12
   10    15        ROPE_INIT                                         3  ~15     'TEST+'
         16        ROPE_ADD                                          1  ~15     ~15, !2
         17        ROPE_END                                          2  ~14     ~15, '%3A+'
         18        ECHO                                                         ~14
   11    19        COUNT                                                ~17     !1
         20        ASSIGN                                                       !3, ~17
   12    21        IS_SMALLER                                                   !3, 3
         22      > JMPZ                                                         ~19, ->26
   13    23    >   FRAMELESS_ICALL_2                implode             ~20     '+and+', !1
         24        ECHO                                                         ~20
   12    25      > JMP                                                          ->56
   15    26    >   IS_EQUAL                                                     !3, 3
         27      > JMPZ                                                         ~21, ->34
   16    28    >   NOP                                                          
         29        FETCH_DIM_R                                          ~23     !1, 2
         30        FAST_CONCAT                                          ~24     'and+', ~23
         31        ASSIGN_DIM                                                   !1, 2
         32        OP_DATA                                                      ~24
   15    33      > JMP                                                          ->54
   17    34    >   IS_SMALLER                                                   3, !3
         35      > JMPZ                                                         ~25, ->54
   18    36    >   SUB                                                  ~26     !3, 3
         37        ASSIGN                                                       !4, ~26
   19    38        INIT_FCALL                                                   'array_splice'
         39        SEND_REF                                                     !1
         40        SEND_VAL                                                     3
         41        SEND_VAR                                                     !4
         42        ROPE_INIT                                         3  ~29     'and+'
         43        ROPE_ADD                                          1  ~29     ~29, !4
         44        ROPE_END                                          2  ~28     ~29, '+other'
         45        IS_SMALLER                                                   1, !4
         46      > JMPZ                                                         ~31, ->49
         47    >   QM_ASSIGN                                            ~32     's'
         48      > JMP                                                          ->50
         49    >   QM_ASSIGN                                            ~32     ''
         50    >   CONCAT                                               ~33     ~28, ~32
         51        INIT_ARRAY                                           ~34     ~33
         52        SEND_VAL                                                     ~34
         53        DO_ICALL                                                     
   21    54    >   FRAMELESS_ICALL_2                implode             ~36     '%2C+', !1
         55        ECHO                                                         ~36
   23    56    >   ECHO                                                         '%0A---%0A'
    9    57      > JMP                                                          ->13
         58    >   FE_FREE                                                      $11
   24    59      > RETURN                                                       1

Generated using Vulcan Logic Dumper, using php 8.5.0


preferences:
160.51 ms | 2591 KiB | 14 Q