3v4l.org

run code in 500+ PHP versions simultaneously
<?php function numToOrdinalWord($num) { $first_word = array('eth', 'First', 'Second', 'Third', 'Fourth', 'Fifth', 'Sixth', 'Seventh', 'Eighth', 'Ninth', 'Tenth', 'Eleventh', 'Twelfth', 'Thirteenth', 'Fourteenth', 'Fifteenth', 'Sixteenth', 'Seventeenth', 'Eighteenth', 'Nineteenth', 'Twentieth'); $second_word = array('', '', 'Twenty', 'Thirty', 'Forty', 'Fifty', 'Sixty', 'Seventy', 'Eighty', 'Ninety'); if ($num <= 20) return ($num == 0) ? 'Zeroth' : $first_word[$num]; $first_num = substr($num, -1, 1); $second_num = substr($num, -2, 1); return $string = str_replace( 'y-eth', 'ieth', $second_word[$second_num] . '-' . $first_word[$first_num] ); } for($i = 0; $i < 100; $i++)echo numToOrdinalWord($i) . PHP_EOL;
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 42) Position 1 = 8
Branch analysis from position: 8
2 jumps found. (Code = 44) Position 1 = 10, Position 2 = 2
Branch analysis from position: 10
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 2
2 jumps found. (Code = 44) Position 1 = 10, Position 2 = 2
Branch analysis from position: 10
Branch analysis from position: 2
filename:       /in/e8jRo
function name:  (null)
number of ops:  11
compiled vars:  !0 = $i
line      #* E I O op                               fetch          ext  return  operands
-----------------------------------------------------------------------------------------
   22     0  E >   ASSIGN                                                       !0, 0
          1      > JMP                                                          ->8
          2    >   INIT_FCALL                                                   'numtoordinalword'
          3        SEND_VAR                                                     !0
          4        DO_FCALL                                          0  $2      
          5        CONCAT                                               ~3      $2, '%0A'
          6        ECHO                                                         ~3
          7        PRE_INC                                                      !0
          8    >   IS_SMALLER                                                   !0, 100
          9      > JMPNZ                                                        ~5, ->2
         10    > > RETURN                                                       1

Function numtoordinalword:
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 43) Position 1 = 5, Position 2 = 12
Branch analysis from position: 5
2 jumps found. (Code = 43) Position 1 = 7, Position 2 = 9
Branch analysis from position: 7
1 jumps found. (Code = 42) Position 1 = 11
Branch analysis from position: 11
1 jumps found. (Code = 62) Position 1 = -2
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
filename:       /in/e8jRo
function name:  numToOrdinalWord
number of ops:  27
compiled vars:  !0 = $num, !1 = $first_word, !2 = $second_word, !3 = $first_num, !4 = $second_num, !5 = $string
line      #* E I O op                               fetch          ext  return  operands
-----------------------------------------------------------------------------------------
    2     0  E >   RECV                                                 !0      
    4     1        ASSIGN                                                       !1, <array>
    8     2        ASSIGN                                                       !2, <array>
   10     3        IS_SMALLER_OR_EQUAL                                          !0, 20
          4      > JMPZ                                                         ~8, ->12
          5    >   IS_EQUAL                                                     !0, 0
          6      > JMPZ                                                         ~9, ->9
          7    >   QM_ASSIGN                                            ~10     'Zeroth'
          8      > JMP                                                          ->11
          9    >   FETCH_DIM_R                                          ~11     !1, !0
         10        QM_ASSIGN                                            ~10     ~11
         11    > > RETURN                                                       ~10
   12    12    >   FRAMELESS_ICALL_3                substr              ~12     !0, -1
         13        OP_DATA                                                      1
         14        ASSIGN                                                       !3, ~12
   13    15        FRAMELESS_ICALL_3                substr              ~14     !0, -2
         16        OP_DATA                                                      1
         17        ASSIGN                                                       !4, ~14
   18    18        FETCH_DIM_R                                          ~16     !2, !4
         19        CONCAT                                               ~17     ~16, '-'
         20        FETCH_DIM_R                                          ~18     !1, !3
         21        CONCAT                                               ~19     ~17, ~18
   15    22        FRAMELESS_ICALL_3                str_replace         ~20     'y-eth', 'ieth'
   18    23        OP_DATA                                                      ~19
   15    24        ASSIGN                                               ~21     !5, ~20
         25      > RETURN                                                       ~21
   20    26*     > RETURN                                                       null

End of function numtoordinalword

Generated using Vulcan Logic Dumper, using php 8.5.0


preferences:
178.6 ms | 3205 KiB | 14 Q