Re: converting decimal to fraction and vice versa
| From: | Ernest E Vogelsinger | Date: | Sun, 10 Nov 2002 09:45:38 +0000 |
| Subject: | Re: converting decimal to fraction and vice versa | ||
| References: | 1 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-123674@lists.php.net to get a copy of this message | ||
At 05:45 10.11.2002, Michael P. Carel said:
--------------------[snip]--------------------
>is there any way to convert decimal numbers to fraction and fraction to
>decimal format. i need to convert the inputed fractional value in the field
>before inserting it to the mysql database, such us 1/2 = 0.5 .
--------------------[snip]--------------------
<?php
$in = '1/2';
eval("\$out = (double)$in;");
echo "$in = $out\n";
?>
Needs a lot of work before and after to check if things are right, but I
believe you get the idea...
--
>O Ernest E. Vogelsinger
(\) ICQ #13394035
^ http://www.vogelsinger.at/