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); return [implode(' ', array_slice($array, 0, -2))] + array_slice($array, -3); } 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/v7UGc
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>
   15     1      > FE_RESET_R                                       $3      !0, ->12
          2    > > FE_FETCH_R                                               $3, !1, ->12
   16     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
   15    11      > JMP                                                      ->2
         12    >   FE_FREE                                                  $3
   17    13      > RETURN                                                   1

Function implodenotlasttwoelements:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/v7UGc
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                                               'implode'
          7        SEND_VAL                                                 '+'
          8        INIT_FCALL                                               'array_slice'
          9        SEND_VAR                                                 !1
         10        SEND_VAL                                                 0
         11        SEND_VAL                                                 -2
         12        DO_ICALL                                         $4      
         13        SEND_VAR                                                 $4
         14        DO_ICALL                                         $5      
         15        INIT_ARRAY                                       ~6      $5
         16        INIT_FCALL                                               'array_slice'
         17        SEND_VAR                                                 !1
         18        SEND_VAL                                                 -3
         19        DO_ICALL                                         $7      
         20        ADD                                              ~8      ~6, $7
         21      > RETURN                                                   ~8
   13    22*     > RETURN                                                   null

End of function implodenotlasttwoelements

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
138.44 ms | 1008 KiB | 18 Q