3v4l.org

run code in 300+ PHP versions simultaneously
<?php function format_date($d) { $m = array(); preg_match('/(\d{4})[\.-\/](\d{2})[\.-\/](\d{2})/', $d, $m); if (count($m) == 4) { $d = "$m[2]/$m[3]/$m[1]"; } return $d; } print_r(format_date('2015-01-01')).PHP_EOL; print_r(format_date('2015/01/02')).PHP_EOL; print_r(format_date('2015.01-03')).PHP_EOL;
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/69PNr
function name:  (null)
number of ops:  25
compiled vars:  none
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   11     0  E >   INIT_FCALL                                               'print_r'
          1        INIT_FCALL                                               'format_date'
          2        SEND_VAL                                                 '2015-01-01'
          3        DO_FCALL                                      0  $0      
          4        SEND_VAR                                                 $0
          5        DO_ICALL                                         $1      
          6        CONCAT                                           ~2      $1, '%0A'
          7        FREE                                                     ~2
   12     8        INIT_FCALL                                               'print_r'
          9        INIT_FCALL                                               'format_date'
         10        SEND_VAL                                                 '2015%2F01%2F02'
         11        DO_FCALL                                      0  $3      
         12        SEND_VAR                                                 $3
         13        DO_ICALL                                         $4      
         14        CONCAT                                           ~5      $4, '%0A'
         15        FREE                                                     ~5
   13    16        INIT_FCALL                                               'print_r'
         17        INIT_FCALL                                               'format_date'
         18        SEND_VAL                                                 '2015.01-03'
         19        DO_FCALL                                      0  $6      
         20        SEND_VAR                                                 $6
         21        DO_ICALL                                         $7      
         22        CONCAT                                           ~8      $7, '%0A'
         23        FREE                                                     ~8
         24      > RETURN                                                   1

Function format_date:
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 43) Position 1 = 10, Position 2 = 19
Branch analysis from position: 10
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 19
filename:       /in/69PNr
function name:  format_date
number of ops:  21
compiled vars:  !0 = $d, !1 = $m
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    2     0  E >   RECV                                             !0      
    3     1        ASSIGN                                                   !1, <array>
    4     2        INIT_FCALL                                               'preg_match'
          3        SEND_VAL                                                 '%2F%28%5Cd%7B4%7D%29%5B%5C.-%5C%2F%5D%28%5Cd%7B2%7D%29%5B%5C.-%5C%2F%5D%28%5Cd%7B2%7D%29%2F'
          4        SEND_VAR                                                 !0
          5        SEND_REF                                                 !1
          6        DO_ICALL                                                 
    5     7        COUNT                                            ~4      !1
          8        IS_EQUAL                                                 ~4, 4
          9      > JMPZ                                                     ~5, ->19
    6    10    >   FETCH_DIM_R                                      ~6      !1, 2
         11        ROPE_INIT                                     5  ~10     ~6
         12        ROPE_ADD                                      1  ~10     ~10, '%2F'
         13        FETCH_DIM_R                                      ~7      !1, 3
         14        ROPE_ADD                                      2  ~10     ~10, ~7
         15        ROPE_ADD                                      3  ~10     ~10, '%2F'
         16        FETCH_DIM_R                                      ~8      !1, 1
         17        ROPE_END                                      4  ~9      ~10, ~8
         18        ASSIGN                                                   !0, ~9
    8    19    > > RETURN                                                   !0
    9    20*     > RETURN                                                   null

End of function format_date

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
170.87 ms | 1403 KiB | 20 Q