3v4l.org

run code in 500+ PHP versions simultaneously
<?php $tests = [ "7.2769482308e+01", "3.43E-6", "2.54E-14", "99.87E-2" ]; foreach($tests as $test){ echo $test, " => ", getFormattedDecimal($test),PHP_EOL; } function getFormattedDecimal($str){ $precision = explode("e", strtolower($str)); $precision = substr($precision[1], 1); // remove + and - operators return sprintf("%.".$precision."f", $str); }
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 77) Position 1 = 2, Position 2 = 11
Branch analysis from position: 2
2 jumps found. (Code = 78) Position 1 = 3, Position 2 = 11
Branch analysis from position: 3
1 jumps found. (Code = 42) Position 1 = 2
Branch analysis from position: 2
Branch analysis from position: 11
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 11
filename:       /in/3hoZu
function name:  (null)
number of ops:  13
compiled vars:  !0 = $tests, !1 = $test
line      #* E I O op                               fetch          ext  return  operands
-----------------------------------------------------------------------------------------
    3     0  E >   ASSIGN                                                       !0, <array>
   10     1      > FE_RESET_R                                           $3      !0, ->11
          2    > > FE_FETCH_R                                                   $3, !1, ->11
   11     3    >   ECHO                                                         !1
          4        ECHO                                                         '+%3D%3E+'
          5        INIT_FCALL_BY_NAME                                           'getFormattedDecimal'
          6        SEND_VAR_EX                                                  !1
          7        DO_FCALL                                          0  $4      
          8        ECHO                                                         $4
          9        ECHO                                                         '%0A'
   10    10      > JMP                                                          ->2
         11    >   FE_FREE                                                      $3
   18    12      > RETURN                                                       1

Function getformatteddecimal:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/3hoZu
function name:  getFormattedDecimal
number of ops:  20
compiled vars:  !0 = $str, !1 = $precision
line      #* E I O op                               fetch          ext  return  operands
-----------------------------------------------------------------------------------------
   14     0  E >   RECV                                                 !0      
   15     1        INIT_FCALL                                                   'explode'
          2        SEND_VAL                                                     'e'
          3        INIT_FCALL                                                   'strtolower'
          4        SEND_VAR                                                     !0
          5        DO_ICALL                                             $2      
          6        SEND_VAR                                                     $2
          7        DO_ICALL                                             $3      
          8        ASSIGN                                                       !1, $3
   16     9        FETCH_DIM_R                                          ~5      !1, 1
         10        FRAMELESS_ICALL_2                substr              ~6      ~5, 1
         11        ASSIGN                                                       !1, ~6
   17    12        INIT_FCALL                                                   'sprintf'
         13        CONCAT                                               ~8      '%25.', !1
         14        CONCAT                                               ~9      ~8, 'f'
         15        SEND_VAL                                                     ~9
         16        SEND_VAR                                                     !0
         17        DO_ICALL                                             $10     
         18      > RETURN                                                       $10
   18    19*     > RETURN                                                       null

End of function getformatteddecimal

Generated using Vulcan Logic Dumper, using php 8.5.0


preferences:
164.49 ms | 1797 KiB | 18 Q