3v4l.org

run code in 300+ PHP versions simultaneously
<?php $testString = "dies ist eine testfirma mit mehr als fünfzig zeichen"; var_dump(breakUpWords($testString, 50)); var_dump(beforeLast($testString, 50)); function beforeLast($str, $before) { $posUntil = strrpos($str, $before); if ($posUntil === false) { return $str; } return substr($str, 0, $posUntil); } function breakUpWords(String $words, int $index) { if (mb_strlen($words) > $index) { return mb_substr($words, 0, 50); } return $words; }
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/lIDm5
function name:  (null)
number of ops:  16
compiled vars:  !0 = $testString
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    3     0  E >   ASSIGN                                                   !0, 'dies+ist+eine+testfirma+mit+mehr+als+f%C3%BCnfzig+zeichen'
    5     1        INIT_FCALL                                               'var_dump'
          2        INIT_FCALL_BY_NAME                                       'breakUpWords'
          3        SEND_VAR_EX                                              !0
          4        SEND_VAL_EX                                              50
          5        DO_FCALL                                      0  $2      
          6        SEND_VAR                                                 $2
          7        DO_ICALL                                                 
    6     8        INIT_FCALL                                               'var_dump'
          9        INIT_FCALL_BY_NAME                                       'beforeLast'
         10        SEND_VAR_EX                                              !0
         11        SEND_VAL_EX                                              50
         12        DO_FCALL                                      0  $4      
         13        SEND_VAR                                                 $4
         14        DO_ICALL                                                 
   24    15      > RETURN                                                   1

Function beforelast:
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 43) Position 1 = 9, Position 2 = 10
Branch analysis from position: 9
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 10
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/lIDm5
function name:  beforeLast
number of ops:  17
compiled vars:  !0 = $str, !1 = $before, !2 = $posUntil
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    8     0  E >   RECV                                             !0      
          1        RECV                                             !1      
   10     2        INIT_FCALL                                               'strrpos'
          3        SEND_VAR                                                 !0
          4        SEND_VAR                                                 !1
          5        DO_ICALL                                         $3      
          6        ASSIGN                                                   !2, $3
   12     7        TYPE_CHECK                                    4          !2
          8      > JMPZ                                                     ~5, ->10
   13     9    > > RETURN                                                   !0
   16    10    >   INIT_FCALL                                               'substr'
         11        SEND_VAR                                                 !0
         12        SEND_VAL                                                 0
         13        SEND_VAR                                                 !2
         14        DO_ICALL                                         $6      
         15      > RETURN                                                   $6
   17    16*     > RETURN                                                   null

End of function beforelast

Function breakupwords:
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 43) Position 1 = 7, Position 2 = 13
Branch analysis from position: 7
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 13
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/lIDm5
function name:  breakUpWords
number of ops:  15
compiled vars:  !0 = $words, !1 = $index
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   19     0  E >   RECV                                             !0      
          1        RECV                                             !1      
   20     2        INIT_FCALL                                               'mb_strlen'
          3        SEND_VAR                                                 !0
          4        DO_ICALL                                         $2      
          5        IS_SMALLER                                               !1, $2
          6      > JMPZ                                                     ~3, ->13
   21     7    >   INIT_FCALL                                               'mb_substr'
          8        SEND_VAR                                                 !0
          9        SEND_VAL                                                 0
         10        SEND_VAL                                                 50
         11        DO_ICALL                                         $4      
         12      > RETURN                                                   $4
   23    13    > > RETURN                                                   !0
   24    14*     > RETURN                                                   null

End of function breakupwords

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
172.59 ms | 1400 KiB | 23 Q