note 58498 deleted from function.explode by bjori
| From: | bjori@php.net | Date: | Mon, 25 Sep 2006 08:07:15 +0000 |
| Subject: | note 58498 deleted from function.explode by bjori | ||
| References: | 1 | Groups: | php.notes |
| Request: | Send a blank email to php-notes+get-117573@lists.php.net to get a copy of this message | ||
Note Submitter: sean at aliencreations dot com
----
Here's a simple function to convert someone's height in inches to a feet/inch ratio using
explode():
function get_height($inches)
{
//divide by 12 to get inches
$feet = $inches/12;
//round decimal so we can divide by 100 and use as percent
$feet = round($feet, 2);
// separate whole from decimal
$parts = explode(".", $feet);
$whole_feet = $parts[0];
//turn remaining into percent of 12
$remaining_inches = round(($parts[1]/100)*12);
$height = $whole_feet."' ".$remaining_inches.""";
return $height;
}