3v4l.org

run code in 300+ PHP versions simultaneously
<?php function after($subject, $search) { return $search === '' ? $subject : array_reverse(explode($search, $subject, 2))[0]; } function before($subject, $search) { if ($search === '') { return $subject; } $result = strstr($subject, (string) $search, true); return $result === false ? $subject : $result; } foreach ([ '5.5.5-10.6.4-MariaDB', '10.3.31-MariaDB-log-cll-lve - MariaDB Server', '5.5.5-10.6.4-MariaDB-1:10.6.4+maria~focal', '5.5.5-10.3.4-MariaDB', '10.3.4-MariaDB', ] as $version) { var_dump($version = before(after($version, '5.5.5-'), '-')); var_dump(version_compare($version, '10.6.0', '>=')); }
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 77) Position 1 = 1, Position 2 = 23
Branch analysis from position: 1
2 jumps found. (Code = 78) Position 1 = 2, Position 2 = 23
Branch analysis from position: 2
1 jumps found. (Code = 42) Position 1 = 1
Branch analysis from position: 1
Branch analysis from position: 23
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 23
filename:       /in/2IqgH
function name:  (null)
number of ops:  25
compiled vars:  !0 = $version
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   20     0  E > > FE_RESET_R                                       $1      <array>, ->23
          1    > > FE_FETCH_R                                               $1, !0, ->23
   26     2    >   INIT_FCALL                                               'var_dump'
          3        INIT_FCALL                                               'before'
          4        INIT_FCALL                                               'after'
          5        SEND_VAR                                                 !0
          6        SEND_VAL                                                 '5.5.5-'
          7        DO_FCALL                                      0  $2      
          8        SEND_VAR                                                 $2
          9        SEND_VAL                                                 '-'
         10        DO_FCALL                                      0  $3      
         11        ASSIGN                                           ~4      !0, $3
         12        SEND_VAL                                                 ~4
         13        DO_ICALL                                                 
   27    14        INIT_FCALL                                               'var_dump'
         15        INIT_FCALL                                               'version_compare'
         16        SEND_VAR                                                 !0
         17        SEND_VAL                                                 '10.6.0'
         18        SEND_VAL                                                 '%3E%3D'
         19        DO_ICALL                                         $6      
         20        SEND_VAR                                                 $6
         21        DO_ICALL                                                 
   20    22      > JMP                                                      ->1
         23    >   FE_FREE                                                  $1
   28    24      > RETURN                                                   1

Function after:
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 43) Position 1 = 4, Position 2 = 6
Branch analysis from position: 4
1 jumps found. (Code = 42) Position 1 = 16
Branch analysis from position: 16
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 6
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/2IqgH
function name:  after
number of ops:  18
compiled vars:  !0 = $subject, !1 = $search
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    3     0  E >   RECV                                             !0      
          1        RECV                                             !1      
    5     2        IS_IDENTICAL                                             !1, ''
          3      > JMPZ                                                     ~2, ->6
          4    >   QM_ASSIGN                                        ~3      !0
          5      > JMP                                                      ->16
          6    >   INIT_FCALL                                               'array_reverse'
          7        INIT_FCALL                                               'explode'
          8        SEND_VAR                                                 !1
          9        SEND_VAR                                                 !0
         10        SEND_VAL                                                 2
         11        DO_ICALL                                         $4      
         12        SEND_VAR                                                 $4
         13        DO_ICALL                                         $5      
         14        FETCH_DIM_R                                      ~6      $5, 0
         15        QM_ASSIGN                                        ~3      ~6
         16    > > RETURN                                                   ~3
    6    17*     > RETURN                                                   null

End of function after

Function before:
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 43) Position 1 = 4, Position 2 = 5
Branch analysis from position: 4
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 5
2 jumps found. (Code = 43) Position 1 = 14, Position 2 = 16
Branch analysis from position: 14
1 jumps found. (Code = 42) Position 1 = 17
Branch analysis from position: 17
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 16
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/2IqgH
function name:  before
number of ops:  19
compiled vars:  !0 = $subject, !1 = $search, !2 = $result
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    8     0  E >   RECV                                             !0      
          1        RECV                                             !1      
   10     2        IS_IDENTICAL                                             !1, ''
          3      > JMPZ                                                     ~3, ->5
   11     4    > > RETURN                                                   !0
   14     5    >   INIT_FCALL                                               'strstr'
          6        SEND_VAR                                                 !0
          7        CAST                                          6  ~4      !1
          8        SEND_VAL                                                 ~4
          9        SEND_VAL                                                 <true>
         10        DO_ICALL                                         $5      
         11        ASSIGN                                                   !2, $5
   16    12        TYPE_CHECK                                    4          !2
         13      > JMPZ                                                     ~7, ->16
         14    >   QM_ASSIGN                                        ~8      !0
         15      > JMP                                                      ->17
         16    >   QM_ASSIGN                                        ~8      !2
         17    > > RETURN                                                   ~8
   17    18*     > RETURN                                                   null

End of function before

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
142.55 ms | 1009 KiB | 20 Q