3v4l.org

run code in 300+ PHP versions simultaneously
<?php $arr = [ // without first Dec, Jan and Jan lines: // all subsequent lines are the current year "Dec 23 21:37:56 hello", "Jan 12 02:08:23 hello", "Jan 16 17:34:33 hello", "Feb 4 12:21:09 hello", "Mar 19 17:07:26 hello", "Apr 1 00:00:03 hello", "Apr 12 23:07:39 hello", "May 21 04:09:34 hello", "Jun 7 23:34:56 hello", "Jul 1 14:45:34 hello", "Aug 13 11:37:23 hello", "Sep 29 07:36:03 hello", "Oct 30 09:01:00 hello", "Nov 10 11:00:03 hello", "Dec 25 21:47:51 hello" ]; var_export( array_reverse( preg_replace_callback( '/^[a-z]{3} +\d+ \d\d:\d\d:\d\d/i', function($m) { static $lastStamp = null; static $year = null; $year ??= date('Y'); $currentStamp = date('m d H:i:s', strtotime($m[0])); if ($currentStamp > ($lastStamp ?? $currentStamp)) { --$year; } $lastStamp = $currentStamp; return "$year $currentStamp"; }, array_reverse($arr) ) ) );
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/rQXWW
function name:  (null)
number of ops:  17
compiled vars:  !0 = $arr
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    3     0  E >   ASSIGN                                                   !0, <array>
   23     1        INIT_FCALL                                               'var_export'
   24     2        INIT_FCALL                                               'array_reverse'
   25     3        INIT_FCALL                                               'preg_replace_callback'
   26     4        SEND_VAL                                                 '%2F%5E%5Ba-z%5D%7B3%7D+%2B%5Cd%2B+%5Cd%5Cd%3A%5Cd%5Cd%3A%5Cd%5Cd%2Fi'
   27     5        DECLARE_LAMBDA_FUNCTION                          ~2      [0]
   37     6        SEND_VAL                                                 ~2
   38     7        INIT_FCALL                                               'array_reverse'
          8        SEND_VAR                                                 !0
          9        DO_ICALL                                         $3      
         10        SEND_VAR                                                 $3
   25    11        DO_ICALL                                         $4      
   38    12        SEND_VAR                                                 $4
   24    13        DO_ICALL                                         $5      
   38    14        SEND_VAR                                                 $5
   23    15        DO_ICALL                                                 
   41    16      > RETURN                                                   1


Dynamic Functions:
Dynamic Function 0
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 43) Position 1 = 23, Position 2 = 24
Branch analysis from position: 23
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 24
filename:       /in/rQXWW
function name:  {closure}
number of ops:  30
compiled vars:  !0 = $m, !1 = $lastStamp, !2 = $year, !3 = $currentStamp
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   27     0  E >   RECV                                             !0      
   28     1        BIND_STATIC                                              !1
   29     2        BIND_STATIC                                              !2
   30     3        COALESCE                                         ~4      !2
          4        INIT_FCALL                                               'date'
          5        SEND_VAL                                                 'Y'
          6        DO_ICALL                                         $5      
          7        ASSIGN                                           ~6      !2, $5
          8        QM_ASSIGN                                        ~4      ~6
          9        FREE                                                     ~4
   31    10        INIT_FCALL                                               'date'
         11        SEND_VAL                                                 'm+d+H%3Ai%3As'
         12        INIT_FCALL                                               'strtotime'
         13        FETCH_DIM_R                                      ~7      !0, 0
         14        SEND_VAL                                                 ~7
         15        DO_ICALL                                         $8      
         16        SEND_VAR                                                 $8
         17        DO_ICALL                                         $9      
         18        ASSIGN                                                   !3, $9
   32    19        COALESCE                                         ~11     !1
         20        QM_ASSIGN                                        ~11     !3
         21        IS_SMALLER                                               ~11, !3
         22      > JMPZ                                                     ~12, ->24
   33    23    >   PRE_DEC                                                  !2
   35    24    >   ASSIGN                                                   !1, !3
   36    25        ROPE_INIT                                     3  ~16     !2
         26        ROPE_ADD                                      1  ~16     ~16, '+'
         27        ROPE_END                                      2  ~15     ~16, !3
         28      > RETURN                                                   ~15
   37    29*     > RETURN                                                   null

End of Dynamic Function 0

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
136.07 ms | 1007 KiB | 18 Q