note 58498 added to function.explode
| From: | sean at aliencreations dot com | Date: | Sun, 06 Nov 2005 13:01:40 +0000 |
| Subject: | note 58498 added to function.explode | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-98157@lists.php.net to get a copy of this message | ||
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;
}
----
Manual Page -- http://www.php.net/manual/en/function.explode.php
Edit -- http://master.php.net/manage/user-notes.php?action=edit+58498
Delete: added to the manual -- http://master.php.net/manage/user-notes.php?action=delete+58498&report=yes&reason=added+to+the+manual
Delete: bad code -- http://master.php.net/manage/user-notes.php?action=delete+58498&report=yes&reason=bad+code
Delete: spam -- http://master.php.net/manage/user-notes.php?action=delete+58498&report=yes&reason=spam
Delete: useless -- http://master.php.net/manage/user-notes.php?action=delete+58498&report=yes&reason=useless
Delete: non-english -- http://master.php.net/manage/user-notes.php?action=delete+58498&report=yes&reason=non-english
Delete: already in docs -- http://master.php.net/manage/user-notes.php?action=delete+58498&report=yes&reason=already+in+docs
Delete: other reasons -- http://master.php.net/manage/user-notes.php?action=delete+58498&report=yes
Reject -- http://master.php.net/manage/user-notes.php?action=reject+58498&report=yes
Search -- http://master.php.net/manage/user-notes.php