3v4l.org

run code in 500+ PHP versions simultaneously
<?php $input = new \DateTime('2017-07-17'); $firstDayOfMonth = new \DateTime($input->format('Y-m-01')); $order = (int)(($input->format('j') - 1) / 7) + 1; function ordinal($number) { $ends = array('th','st','nd','rd','th','th','th','th','th','th'); if ((($number % 100) >= 11) && (($number%100) <= 13)) return $number. 'th'; else return $number. $ends[$number % 10]; } echo ordinal($order).' '.$input->format('l');
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/dg5Xa
function name:  (null)
number of ops:  29
compiled vars:  !0 = $input, !1 = $firstDayOfMonth, !2 = $order
line      #* E I O op                               fetch          ext  return  operands
-----------------------------------------------------------------------------------------
    3     0  E >   NEW                                                  $3      'DateTime'
          1        SEND_VAL_EX                                                  '2017-07-17'
          2        DO_FCALL                                          0          
          3        ASSIGN                                                       !0, $3
    4     4        NEW                                                  $6      'DateTime'
          5        INIT_METHOD_CALL                                             !0, 'format'
          6        SEND_VAL_EX                                                  'Y-m-01'
          7        DO_FCALL                                          0  $7      
          8        SEND_VAR_NO_REF_EX                                           $7
          9        DO_FCALL                                          0          
         10        ASSIGN                                                       !1, $6
    5    11        INIT_METHOD_CALL                                             !0, 'format'
         12        SEND_VAL_EX                                                  'j'
         13        DO_FCALL                                          0  $10     
         14        SUB                                                  ~11     $10, 1
         15        DIV                                                  ~12     ~11, 7
         16        CAST                                              4  ~13     ~12
         17        ADD                                                  ~14     ~13, 1
         18        ASSIGN                                                       !2, ~14
   15    19        INIT_FCALL                                                   'ordinal'
         20        SEND_VAR                                                     !2
         21        DO_FCALL                                          0  $16     
         22        CONCAT                                               ~17     $16, '+'
         23        INIT_METHOD_CALL                                             !0, 'format'
         24        SEND_VAL_EX                                                  'l'
         25        DO_FCALL                                          0  $18     
         26        CONCAT                                               ~19     ~17, $18
         27        ECHO                                                         ~19
         28      > RETURN                                                       1

Function ordinal:
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 46) Position 1 = 5, Position 2 = 8
Branch analysis from position: 5
2 jumps found. (Code = 43) Position 1 = 9, Position 2 = 12
Branch analysis from position: 9
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 12
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 8
filename:       /in/dg5Xa
function name:  ordinal
number of ops:  17
compiled vars:  !0 = $number, !1 = $ends
line      #* E I O op                               fetch          ext  return  operands
-----------------------------------------------------------------------------------------
    7     0  E >   RECV                                                 !0      
    8     1        ASSIGN                                                       !1, <array>
    9     2        MOD                                                  ~3      !0, 100
          3        IS_SMALLER_OR_EQUAL                                  ~4      11, ~3
          4      > JMPZ_EX                                              ~4      ~4, ->8
          5    >   MOD                                                  ~5      !0, 100
          6        IS_SMALLER_OR_EQUAL                                  ~6      ~5, 13
          7        BOOL                                                 ~4      ~6
          8    > > JMPZ                                                         ~4, ->12
   10     9    >   CONCAT                                               ~7      !0, 'th'
         10      > RETURN                                                       ~7
    9    11*       JMP                                                          ->16
   12    12    >   MOD                                                  ~8      !0, 10
         13        FETCH_DIM_R                                          ~9      !1, ~8
         14        CONCAT                                               ~10     !0, ~9
         15      > RETURN                                                       ~10
   13    16*     > RETURN                                                       null

End of function ordinal

Generated using Vulcan Logic Dumper, using php 8.5.0


preferences:
160.18 ms | 3274 KiB | 14 Q