3v4l.org

run code in 300+ 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 = 64
Branch analysis from position: 13
2 jumps found. (Code = 78) Position 1 = 14, Position 2 = 64
Branch analysis from position: 14
2 jumps found. (Code = 43) Position 1 = 23, Position 2 = 29
Branch analysis from position: 23
1 jumps found. (Code = 42) Position 1 = 62
Branch analysis from position: 62
1 jumps found. (Code = 42) Position 1 = 13
Branch analysis from position: 13
Branch analysis from position: 29
2 jumps found. (Code = 43) Position 1 = 31, Position 2 = 37
Branch analysis from position: 31
1 jumps found. (Code = 42) Position 1 = 57
Branch analysis from position: 57
1 jumps found. (Code = 42) Position 1 = 13
Branch analysis from position: 13
Branch analysis from position: 37
2 jumps found. (Code = 43) Position 1 = 39, Position 2 = 57
Branch analysis from position: 39
2 jumps found. (Code = 43) Position 1 = 50, Position 2 = 52
Branch analysis from position: 50
1 jumps found. (Code = 42) Position 1 = 53
Branch analysis from position: 53
1 jumps found. (Code = 42) Position 1 = 13
Branch analysis from position: 13
Branch analysis from position: 52
1 jumps found. (Code = 42) Position 1 = 13
Branch analysis from position: 13
Branch analysis from position: 57
Branch analysis from position: 64
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 64
filename:       /in/P2Keg
function name:  (null)
number of ops:  66
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, ->64
         13    > > FE_FETCH_R                                       ~12     $11, !1, ->64
         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, ->29
   13    23    >   INIT_FCALL                                               'implode'
         24        SEND_VAL                                                 '+and+'
         25        SEND_VAR                                                 !1
         26        DO_ICALL                                         $20     
         27        ECHO                                                     $20
   12    28      > JMP                                                      ->62
   15    29    >   IS_EQUAL                                                 !3, 3
         30      > JMPZ                                                     ~21, ->37
   16    31    >   NOP                                                      
         32        FETCH_DIM_R                                      ~23     !1, 2
         33        FAST_CONCAT                                      ~24     'and+', ~23
         34        ASSIGN_DIM                                               !1, 2
         35        OP_DATA                                                  ~24
   15    36      > JMP                                                      ->57
   17    37    >   IS_SMALLER                                               3, !3
         38      > JMPZ                                                     ~25, ->57
   18    39    >   SUB                                              ~26     !3, 3
         40        ASSIGN                                                   !4, ~26
   19    41        INIT_FCALL                                               'array_splice'
         42        SEND_REF                                                 !1
         43        SEND_VAL                                                 3
         44        SEND_VAR                                                 !4
         45        ROPE_INIT                                     3  ~29     'and+'
         46        ROPE_ADD                                      1  ~29     ~29, !4
         47        ROPE_END                                      2  ~28     ~29, '+other'
         48        IS_SMALLER                                               1, !4
         49      > JMPZ                                                     ~31, ->52
         50    >   QM_ASSIGN                                        ~32     's'
         51      > JMP                                                      ->53
         52    >   QM_ASSIGN                                        ~32     ''
         53    >   CONCAT                                           ~33     ~28, ~32
         54        INIT_ARRAY                                       ~34     ~33
         55        SEND_VAL                                                 ~34
         56        DO_ICALL                                                 
   21    57    >   INIT_FCALL                                               'implode'
         58        SEND_VAL                                                 '%2C+'
         59        SEND_VAR                                                 !1
         60        DO_ICALL                                         $36     
         61        ECHO                                                     $36
   23    62    >   ECHO                                                     '%0A---%0A'
    9    63      > JMP                                                      ->13
         64    >   FE_FREE                                                  $11
   24    65      > RETURN                                                   1

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
145.25 ms | 1008 KiB | 15 Q