3v4l.org

run code in 300+ PHP versions simultaneously
<?php echo convert_fraction_to_decimal('3 1/16'); function convert_fraction_to_decimal( $fraction_string){ print_r($fraction_string); $fraction_string_array = explode( $fraction_string, ' '); print_r($fraction_string_array); $whole_number = $fraction_string_array[0]; $fraction_number = $fraction_string_array[1]; $fraction_decimal = 0; if( $fraction_number != 0){ $fraction_number_array = explode($fraction_number, '/'); $fraction_decimal = $fraction_number_array[0] / $fraction_number_array[1]; } $return_number = $fraction_number + $fraction_decimal; return $return_number; }
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/S6sFM
function name:  (null)
number of ops:  5
compiled vars:  none
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    3     0  E >   INIT_FCALL_BY_NAME                                       'convert_fraction_to_decimal'
          1        SEND_VAL_EX                                              '3+1%2F16'
          2        DO_FCALL                                      0  $0      
          3        ECHO                                                     $0
   19     4      > RETURN                                                   1

Function convert_fraction_to_decimal:
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 43) Position 1 = 19, Position 2 = 28
Branch analysis from position: 19
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 28
filename:       /in/S6sFM
function name:  convert_fraction_to_decimal
number of ops:  32
compiled vars:  !0 = $fraction_string, !1 = $fraction_string_array, !2 = $whole_number, !3 = $fraction_number, !4 = $fraction_decimal, !5 = $fraction_number_array, !6 = $return_number
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    5     0  E >   RECV                                             !0      
    6     1        INIT_FCALL                                               'print_r'
          2        SEND_VAR                                                 !0
          3        DO_ICALL                                                 
    7     4        INIT_FCALL                                               'explode'
          5        SEND_VAR                                                 !0
          6        SEND_VAL                                                 '+'
          7        DO_ICALL                                         $8      
          8        ASSIGN                                                   !1, $8
    8     9        INIT_FCALL                                               'print_r'
         10        SEND_VAR                                                 !1
         11        DO_ICALL                                                 
    9    12        FETCH_DIM_R                                      ~11     !1, 0
         13        ASSIGN                                                   !2, ~11
   10    14        FETCH_DIM_R                                      ~13     !1, 1
         15        ASSIGN                                                   !3, ~13
   11    16        ASSIGN                                                   !4, 0
   12    17        IS_NOT_EQUAL                                             !3, 0
         18      > JMPZ                                                     ~16, ->28
   13    19    >   INIT_FCALL                                               'explode'
         20        SEND_VAR                                                 !3
         21        SEND_VAL                                                 '%2F'
         22        DO_ICALL                                         $17     
         23        ASSIGN                                                   !5, $17
   14    24        FETCH_DIM_R                                      ~19     !5, 0
         25        FETCH_DIM_R                                      ~20     !5, 1
         26        DIV                                              ~21     ~19, ~20
         27        ASSIGN                                                   !4, ~21
   16    28    >   ADD                                              ~23     !3, !4
         29        ASSIGN                                                   !6, ~23
   18    30      > RETURN                                                   !6
   19    31*     > RETURN                                                   null

End of function convert_fraction_to_decimal

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
147.06 ms | 1400 KiB | 17 Q