3v4l.org

run code in 500+ PHP versions simultaneously
<?php function glue($array, $allButLast = ', ', $last = ' and ') { if (empty($array)) { return ''; } $glued = implode($allButLast, $array); $pos = strrpos($glued, $allButLast); if ($pos !== false) { $glued = substr_replace($glued, $last, $pos, strlen($allButLast)); } return $glued; } $array = [ 'bar', 'food', 'foo, bar', ]; echo glue($array);
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/PScoI
function name:  (null)
number of ops:  6
compiled vars:  !0 = $array
line      #* E I O op                               fetch          ext  return  operands
-----------------------------------------------------------------------------------------
   17     0  E >   ASSIGN                                                       !0, <array>
   22     1        INIT_FCALL                                                   'glue'
          2        SEND_VAR                                                     !0
          3        DO_FCALL                                          0  $2      
          4        ECHO                                                         $2
          5      > RETURN                                                       1

Function glue:
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 43) Position 1 = 5, Position 2 = 6
Branch analysis from position: 5
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 6
2 jumps found. (Code = 43) Position 1 = 15, Position 2 = 23
Branch analysis from position: 15
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 23
filename:       /in/PScoI
function name:  glue
number of ops:  25
compiled vars:  !0 = $array, !1 = $allButLast, !2 = $last, !3 = $glued, !4 = $pos
line      #* E I O op                               fetch          ext  return  operands
-----------------------------------------------------------------------------------------
    3     0  E >   RECV                                                 !0      
          1        RECV_INIT                                            !1      '%2C+'
          2        RECV_INIT                                            !2      '+and+'
    5     3        ISSET_ISEMPTY_CV                                             !0
          4      > JMPZ                                                         ~5, ->6
    6     5    > > RETURN                                                       ''
    8     6    >   FRAMELESS_ICALL_2                implode             ~6      !1, !0
          7        ASSIGN                                                       !3, ~6
    9     8        INIT_FCALL                                                   'strrpos'
          9        SEND_VAR                                                     !3
         10        SEND_VAR                                                     !1
         11        DO_ICALL                                             $8      
         12        ASSIGN                                                       !4, $8
   10    13        TYPE_CHECK                                      1018          !4
         14      > JMPZ                                                         ~10, ->23
   11    15    >   INIT_FCALL                                                   'substr_replace'
         16        SEND_VAR                                                     !3
         17        SEND_VAR                                                     !2
         18        SEND_VAR                                                     !4
         19        STRLEN                                               ~11     !1
         20        SEND_VAL                                                     ~11
         21        DO_ICALL                                             $12     
         22        ASSIGN                                                       !3, $12
   14    23    > > RETURN                                                       !3
   15    24*     > RETURN                                                       null

End of function glue

Generated using Vulcan Logic Dumper, using php 8.5.0


preferences:
179.49 ms | 1590 KiB | 16 Q