3v4l.org

run code in 300+ PHP versions simultaneously
<?php function trimdata($str, $start = 0, $len = 255, $sep = '|') { if($start == 0 && strlen($str) <= $len) return $str; if(strlen($str) - $start <= $len) return substr($str, $start, $len); if($start >= 0) { $str = substr($str, $start, $len + 1); //In-case the last record is complete $pos = strrpos($str, $sep, -1); $str = substr($str, $start, $pos); } else { } return $str; } $str = "0|1|27|36|4|5|6|7|8|9|0"; var_dump($ret = trimdata($str, 1, 10), strlen($ret));
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/BQ4FP
function name:  (null)
number of ops:  13
compiled vars:  !0 = $str, !1 = $ret
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   15     0  E >   ASSIGN                                                   !0, '0%7C1%7C27%7C36%7C4%7C5%7C6%7C7%7C8%7C9%7C0'
   16     1        INIT_FCALL                                               'var_dump'
          2        INIT_FCALL                                               'trimdata'
          3        SEND_VAR                                                 !0
          4        SEND_VAL                                                 1
          5        SEND_VAL                                                 10
          6        DO_FCALL                                      0  $3      
          7        ASSIGN                                           ~4      !1, $3
          8        SEND_VAL                                                 ~4
          9        STRLEN                                           ~5      !1
         10        SEND_VAL                                                 ~5
         11        DO_ICALL                                                 
         12      > RETURN                                                   1

Function trimdata:
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 46) Position 1 = 6, Position 2 = 9
Branch analysis from position: 6
2 jumps found. (Code = 43) Position 1 = 10, Position 2 = 11
Branch analysis from position: 10
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 11
2 jumps found. (Code = 43) Position 1 = 15, Position 2 = 21
Branch analysis from position: 15
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 21
2 jumps found. (Code = 43) Position 1 = 23, Position 2 = 43
Branch analysis from position: 23
1 jumps found. (Code = 42) Position 1 = 43
Branch analysis from position: 43
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 43
Branch analysis from position: 9
filename:       /in/BQ4FP
function name:  trimdata
number of ops:  45
compiled vars:  !0 = $str, !1 = $start, !2 = $len, !3 = $sep, !4 = $pos
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    2     0  E >   RECV                                             !0      
          1        RECV_INIT                                        !1      0
          2        RECV_INIT                                        !2      255
          3        RECV_INIT                                        !3      '%7C'
    3     4        IS_EQUAL                                         ~5      !1, 0
          5      > JMPZ_EX                                          ~5      ~5, ->9
          6    >   STRLEN                                           ~6      !0
          7        IS_SMALLER_OR_EQUAL                              ~7      ~6, !2
          8        BOOL                                             ~5      ~7
          9    > > JMPZ                                                     ~5, ->11
         10    > > RETURN                                                   !0
    4    11    >   STRLEN                                           ~8      !0
         12        SUB                                              ~9      ~8, !1
         13        IS_SMALLER_OR_EQUAL                                      ~9, !2
         14      > JMPZ                                                     ~10, ->21
         15    >   INIT_FCALL                                               'substr'
         16        SEND_VAR                                                 !0
         17        SEND_VAR                                                 !1
         18        SEND_VAR                                                 !2
         19        DO_ICALL                                         $11     
         20      > RETURN                                                   $11
    5    21    >   IS_SMALLER_OR_EQUAL                                      0, !1
         22      > JMPZ                                                     ~12, ->43
    6    23    >   INIT_FCALL                                               'substr'
         24        SEND_VAR                                                 !0
         25        SEND_VAR                                                 !1
         26        ADD                                              ~13     !2, 1
         27        SEND_VAL                                                 ~13
         28        DO_ICALL                                         $14     
         29        ASSIGN                                                   !0, $14
    7    30        INIT_FCALL                                               'strrpos'
         31        SEND_VAR                                                 !0
         32        SEND_VAR                                                 !3
         33        SEND_VAL                                                 -1
         34        DO_ICALL                                         $16     
         35        ASSIGN                                                   !4, $16
    8    36        INIT_FCALL                                               'substr'
         37        SEND_VAR                                                 !0
         38        SEND_VAR                                                 !1
         39        SEND_VAR                                                 !4
         40        DO_ICALL                                         $18     
         41        ASSIGN                                                   !0, $18
         42      > JMP                                                      ->43
   12    43    > > RETURN                                                   !0
   14    44*     > RETURN                                                   null

End of function trimdata

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
156.19 ms | 1394 KiB | 20 Q