3v4l.org

run code in 200+ php & hhvm versions
Bugs & Features
<?php function prettynum($num, $dollar = null) { global $mtgdb; $out = strrev((string) preg_replace('/(\d{3})(?=\d)(?!\d*\.)/', '$1,', strrev($num))); if($dollar && is_numeric($num)) { $out = "$" . $out; } return $out; } echo prettynum(123456),"<br />"; echo prettynum(123456, 1),"<br />"; echo number_format(123456);
Finding entry points
Branch analysis from position: 0
Jump found. Position 1 = -2
filename:       /in/AlCra
function name:  (null)
number of ops:  17
compiled vars:  none
line     #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   2     0  E >   NOP                                                      
  11     1        INIT_FCALL                                               'prettynum'
         2        SEND_VAL                                                 123456
         3        DO_FCALL                                      0  $0      
         4        ECHO                                                     $0
         5        ECHO                                                     '%3Cbr+%2F%3E'
  12     6        INIT_FCALL                                               'prettynum'
         7        SEND_VAL                                                 123456
         8        SEND_VAL                                                 1
         9        DO_FCALL                                      0  $1      
        10        ECHO                                                     $1
        11        ECHO                                                     '%3Cbr+%2F%3E'
  13    12        INIT_FCALL                                               'number_format'
        13        SEND_VAL                                                 123456
        14        DO_ICALL                                         $2      
        15        ECHO                                                     $2
        16      > RETURN                                                   1

Function prettynum:
Finding entry points
Branch analysis from position: 0
Jump found. Position 1 = 17, Position 2 = 21
Branch analysis from position: 17
Jump found. Position 1 = 22, Position 2 = 24
Branch analysis from position: 22
Jump found. Position 1 = -2
Branch analysis from position: 24
Branch analysis from position: 21
filename:       /in/AlCra
function name:  prettynum
number of ops:  26
compiled vars:  !0 = $num, !1 = $dollar, !2 = $mtgdb, !3 = $out
line     #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   2     0  E >   RECV                                             !0      
         1        RECV_INIT                                        !1      null
   3     2        BIND_GLOBAL                                              !2, 'mtgdb'
   4     3        INIT_FCALL                                               'strrev'
         4        INIT_FCALL                                               'preg_replace'
         5        SEND_VAL                                                 '%2F%28%5Cd%7B3%7D%29%28%3F%3D%5Cd%29%28%3F%21%5Cd%2A%5C.%29%2F'
         6        SEND_VAL                                                 '%241%2C'
         7        INIT_FCALL                                               'strrev'
         8        SEND_VAR                                                 !0
         9        DO_ICALL                                         $4      
        10        SEND_VAR                                                 $4
        11        DO_ICALL                                         $5      
        12        CAST                                          6  ~6      $5
        13        SEND_VAL                                                 ~6
        14        DO_ICALL                                         $7      
        15        ASSIGN                                                   !3, $7
   5    16      > JMPZ_EX                                          ~9      !1, ->21
        17    >   INIT_FCALL                                               'is_numeric'
        18        SEND_VAR                                                 !0
        19        DO_ICALL                                         $10     
        20        BOOL                                             ~9      $10
        21    > > JMPZ                                                     ~9, ->24
   6    22    >   CONCAT                                           ~11     '%24', !3
        23        ASSIGN                                                   !3, ~11
   8    24    > > RETURN                                                   !3
   9    25*     > RETURN                                                   null

End of function prettynum

Generated using Vulcan Logic Dumper, using php 7.3.0