3v4l.org

run code in 300+ PHP versions simultaneously
<?php // Everything you enter here will be executed by our servers. Try it! $str = "A, B, C, D, E"; $components = explode(", ", $str); if (count($components) <= 1) { //If there's only one word, and no commas or whatever. echo $str; die(); //You don't have to *die* here, just stop the rest of the following from executing. } $last = array_pop($components); //This will remove the last element from the array, then put it in the $last variable. echo implode(", ", $components) . " &amp; " . $last;
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 43) Position 1 = 9, Position 2 = 11
Branch analysis from position: 9
1 jumps found. (Code = 79) Position 1 = -2
Branch analysis from position: 11
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/jXdld
function name:  (null)
number of ops:  23
compiled vars:  !0 = $str, !1 = $components, !2 = $last
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    4     0  E >   ASSIGN                                                   !0, 'A%2C+B%2C+C%2C+D%2C+E'
    6     1        INIT_FCALL                                               'explode'
          2        SEND_VAL                                                 '%2C+'
          3        SEND_VAR                                                 !0
          4        DO_ICALL                                         $4      
          5        ASSIGN                                                   !1, $4
    8     6        COUNT                                            ~6      !1
          7        IS_SMALLER_OR_EQUAL                                      ~6, 1
          8      > JMPZ                                                     ~7, ->11
    9     9    >   ECHO                                                     !0
   10    10      > EXIT                                                     
   13    11    >   INIT_FCALL                                               'array_pop'
         12        SEND_REF                                                 !1
         13        DO_ICALL                                         $8      
         14        ASSIGN                                                   !2, $8
   15    15        INIT_FCALL                                               'implode'
         16        SEND_VAL                                                 '%2C+'
         17        SEND_VAR                                                 !1
         18        DO_ICALL                                         $10     
         19        CONCAT                                           ~11     $10, '+%26amp%3B+'
         20        CONCAT                                           ~12     ~11, !2
         21        ECHO                                                     ~12
         22      > RETURN                                                   1

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
163.74 ms | 1395 KiB | 19 Q