3v4l.org

run code in 300+ PHP versions simultaneously
<?php $word = new NumberFormatter('en', NumberFormatter::SPELLOUT); $number = [1,5,10,15, 99, 10000000]; rsort($number); // sort by highest number first // make words from numbers $text = array_map(fn($num) => $word->format($num), $number); // example $str = '1 5 10 15 99 10000000'; echo str_replace($number, $text, $str);
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/SWqo1
function name:  (null)
number of ops:  25
compiled vars:  !0 = $word, !1 = $number, !2 = $text, !3 = $str
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    2     0  E >   NEW                                              $4      'NumberFormatter'
          1        SEND_VAL_EX                                              'en'
          2        FETCH_CLASS_CONSTANT                             ~5      'NumberFormatter', 'SPELLOUT'
          3        SEND_VAL_EX                                              ~5
          4        DO_FCALL                                      0          
          5        ASSIGN                                                   !0, $4
    4     6        ASSIGN                                                   !1, <array>
    5     7        INIT_FCALL                                               'rsort'
          8        SEND_REF                                                 !1
          9        DO_ICALL                                                 
    8    10        INIT_FCALL                                               'array_map'
         11        DECLARE_LAMBDA_FUNCTION                          ~10     [0]
         12        BIND_LEXICAL                                             ~10, !0
         13        SEND_VAL                                                 ~10
         14        SEND_VAR                                                 !1
         15        DO_ICALL                                         $11     
         16        ASSIGN                                                   !2, $11
   11    17        ASSIGN                                                   !3, '1+5+10+15+99+10000000'
   12    18        INIT_FCALL                                               'str_replace'
         19        SEND_VAR                                                 !1
         20        SEND_VAR                                                 !2
         21        SEND_VAR                                                 !3
         22        DO_ICALL                                         $14     
         23        ECHO                                                     $14
         24      > RETURN                                                   1


Dynamic Functions:
Dynamic Function 0
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/SWqo1
function name:  {closure}
number of ops:  7
compiled vars:  !0 = $num, !1 = $word
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    8     0  E >   RECV                                             !0      
          1        BIND_STATIC                                              !1
          2        INIT_METHOD_CALL                                         !1, 'format'
          3        SEND_VAR_EX                                              !0
          4        DO_FCALL                                      0  $2      
          5      > RETURN                                                   $2
          6*     > RETURN                                                   null

End of Dynamic Function 0

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
148.61 ms | 1008 KiB | 16 Q