3v4l.org

run code in 500+ PHP versions simultaneously
<?php /** * SO Q&A: Comma separated list from array with "and" before last element * * @link https://stackoverflow.com/a/18476721/367456 */ $numbers = range(1, 4); array_splice($numbers, -2, 2, implode(' and ', array_slice($numbers, -2))); echo implode(', ', $numbers); # prints "1, 2, 3 and 4"
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/DHPla
function name:  (null)
number of ops:  19
compiled vars:  !0 = $numbers
line      #* E I O op                               fetch          ext  return  operands
-----------------------------------------------------------------------------------------
    8     0  E >   INIT_FCALL                                                   'range'
          1        SEND_VAL                                                     1
          2        SEND_VAL                                                     4
          3        DO_ICALL                                             $1      
          4        ASSIGN                                                       !0, $1
   10     5        INIT_FCALL                                                   'array_splice'
          6        SEND_REF                                                     !0
          7        SEND_VAL                                                     -2
          8        SEND_VAL                                                     2
          9        INIT_FCALL                                                   'array_slice'
         10        SEND_VAR                                                     !0
         11        SEND_VAL                                                     -2
         12        DO_ICALL                                             $3      
         13        FRAMELESS_ICALL_2                implode             ~4      '+and+', $3
         14        SEND_VAL                                                     ~4
         15        DO_ICALL                                                     
   12    16        FRAMELESS_ICALL_2                implode             ~6      '%2C+', !0
         17        ECHO                                                         ~6
         18      > RETURN                                                       1

Generated using Vulcan Logic Dumper, using php 8.5.0


preferences:
167.25 ms | 1854 KiB | 16 Q