Exemplo n.º 1
0
 public static function convert_decimal_to_fraction($decimal)
 {
     $big_fraction = SocialChef_Theme_Utils::float_to_rat($decimal, 0.1);
     if ($big_fraction) {
         $num_array = explode('/', $big_fraction);
         if (count($num_array) > 1) {
             $numerator = $num_array[0];
             $denominator = $num_array[1];
             if ($denominator) {
                 $whole_number = floor($numerator / $denominator);
                 $numerator = $numerator % $denominator;
                 if ($numerator == 0) {
                     return $whole_number;
                 } else {
                     if ($whole_number == 0) {
                         return $numerator . '/' . $denominator;
                     } else {
                         return $whole_number . ' ' . $numerator . '/' . $denominator;
                     }
                 }
             }
         }
     }
     return 0;
 }