3v4l.org

run code in 300+ PHP versions simultaneously
<?php $strings = [ 'Stack Over Flow Abcpqr (UR)', 'Fluency in English Conversation Defklmno (1WIR)', 'English Proficiency GHI (2WIR)', 'Testing ADG (3WIR)', ]; function implodeNotLastTwoElements($string) { $array = explode(' ', $string); array_splice($array, 0, -2, implode(' ', array_slice($array, 0, -2))); return $array; } foreach ($strings as $string) { echo json_encode(implodeNotLastTwoElements($string)) . "\n"; }
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 77) Position 1 = 2, Position 2 = 12
Branch analysis from position: 2
2 jumps found. (Code = 78) Position 1 = 3, Position 2 = 12
Branch analysis from position: 3
1 jumps found. (Code = 42) Position 1 = 2
Branch analysis from position: 2
Branch analysis from position: 12
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 12
filename:       /in/6aCb6
function name:  (null)
number of ops:  14
compiled vars:  !0 = $strings, !1 = $string
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    3     0  E >   ASSIGN                                                   !0, <array>
   16     1      > FE_RESET_R                                       $3      !0, ->12
          2    > > FE_FETCH_R                                               $3, !1, ->12
   17     3    >   INIT_FCALL                                               'json_encode'
          4        INIT_FCALL                                               'implodenotlasttwoelements'
          5        SEND_VAR                                                 !1
          6        DO_FCALL                                      0  $4      
          7        SEND_VAR                                                 $4
          8        DO_ICALL                                         $5      
          9        CONCAT                                           ~6      $5, '%0A'
         10        ECHO                                                     ~6
   16    11      > JMP                                                      ->2
         12    >   FE_FREE                                                  $3
   18    13      > RETURN                                                   1

Function implodenotlasttwoelements:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/6aCb6
function name:  implodeNotLastTwoElements
number of ops:  23
compiled vars:  !0 = $string, !1 = $array
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   10     0  E >   RECV                                             !0      
   11     1        INIT_FCALL                                               'explode'
          2        SEND_VAL                                                 '+'
          3        SEND_VAR                                                 !0
          4        DO_ICALL                                         $2      
          5        ASSIGN                                                   !1, $2
   12     6        INIT_FCALL                                               'array_splice'
          7        SEND_REF                                                 !1
          8        SEND_VAL                                                 0
          9        SEND_VAL                                                 -2
         10        INIT_FCALL                                               'implode'
         11        SEND_VAL                                                 '+'
         12        INIT_FCALL                                               'array_slice'
         13        SEND_VAR                                                 !1
         14        SEND_VAL                                                 0
         15        SEND_VAL                                                 -2
         16        DO_ICALL                                         $4      
         17        SEND_VAR                                                 $4
         18        DO_ICALL                                         $5      
         19        SEND_VAR                                                 $5
         20        DO_ICALL                                                 
   13    21      > RETURN                                                   !1
   14    22*     > RETURN                                                   null

End of function implodenotlasttwoelements

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
149.02 ms | 1017 KiB | 19 Q