3v4l.org

run code in 500+ PHP versions simultaneously
<?php $inputs = [ '44d', '5h 53s', '1d 3h 16m 2s', '2d 57m', '3m', '2m 22s', '6d 6s' ]; foreach ($inputs as $input) { preg_match('/^(?:(\d+)d ?)?(?:(\d+)h ?)?(?:(\d+)m ?)?(?:(\d+)s)?$/', $input, $m); echo "$input = " . ((int) ($m[1] ?? 0) * 86400) + ((int) ($m[2] ?? 0) * 3600) + ((int) ($m[3] ?? 0) * 60) + (int) ($m[4] ?? 0) . " seconds\n"; }
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 77) Position 1 = 2, Position 2 = 36
Branch analysis from position: 2
2 jumps found. (Code = 78) Position 1 = 3, Position 2 = 36
Branch analysis from position: 3
1 jumps found. (Code = 42) Position 1 = 2
Branch analysis from position: 2
Branch analysis from position: 36
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 36
filename:       /in/PDrhI
function name:  (null)
number of ops:  38
compiled vars:  !0 = $inputs, !1 = $input, !2 = $m
line      #* E I O op                               fetch          ext  return  operands
-----------------------------------------------------------------------------------------
    3     0  E >   ASSIGN                                                       !0, <array>
   13     1      > FE_RESET_R                                           $4      !0, ->36
          2    > > FE_FETCH_R                                                   $4, !1, ->36
   14     3    >   INIT_FCALL                                                   'preg_match'
          4        SEND_VAL                                                     '%2F%5E%28%3F%3A%28%5Cd%2B%29d+%3F%29%3F%28%3F%3A%28%5Cd%2B%29h+%3F%29%3F%28%3F%3A%28%5Cd%2B%29m+%3F%29%3F%28%3F%3A%28%5Cd%2B%29s%29%3F%24%2F'
          5        SEND_VAR                                                     !1
          6        SEND_REF                                                     !2
          7        DO_ICALL                                                     
   15     8        NOP                                                          
          9        FAST_CONCAT                                          ~6      !1, '+%3D+'
         10        FETCH_DIM_IS                                         ~7      !2, 1
         11        COALESCE                                             ~8      ~7
         12        QM_ASSIGN                                            ~8      0
         13        CAST                                              4  ~9      ~8
         14        MUL                                                  ~10     ~9, 86400
         15        FETCH_DIM_IS                                         ~11     !2, 2
         16        COALESCE                                             ~12     ~11
         17        QM_ASSIGN                                            ~12     0
         18        CAST                                              4  ~13     ~12
         19        MUL                                                  ~14     ~13, 3600
         20        ADD                                                  ~15     ~10, ~14
         21        FETCH_DIM_IS                                         ~16     !2, 3
         22        COALESCE                                             ~17     ~16
         23        QM_ASSIGN                                            ~17     0
         24        CAST                                              4  ~18     ~17
         25        MUL                                                  ~19     ~18, 60
         26        ADD                                                  ~20     ~15, ~19
         27        FETCH_DIM_IS                                         ~21     !2, 4
         28        COALESCE                                             ~22     ~21
         29        QM_ASSIGN                                            ~22     0
         30        CAST                                              4  ~23     ~22
         31        ADD                                                  ~24     ~20, ~23
         32        CONCAT                                               ~25     ~6, ~24
         33        CONCAT                                               ~26     ~25, '+seconds%0A'
         34        ECHO                                                         ~26
   13    35      > JMP                                                          ->2
         36    >   FE_FREE                                                      $4
   16    37      > RETURN                                                       1

Generated using Vulcan Logic Dumper, using php 8.5.0


preferences:
196.38 ms | 1780 KiB | 14 Q