# Posted By

rossuber on 06/30/09

# Statistics

Viewed 649 times
Favorited by 1 user(s)

# Golden mean calculator for a given length of time

/ Published in: PHP  This little bit of code is a calculator of the "golden mean" of a given length of time. For example: given a length of 1 minute and 0 seconds, the answer given will be 0:00:37. See U2's "With or Without You", the Greek Parthenon, the human body, etc.
Substitute your own preferred method of input filtering.
I am just a PHP amateur so don't hate on my code!

Copy this code and paste it in your HTML
`<?phprequire_once("class.inputfilter_clean.php");function sec2hms ( \$sec, \$padHours = false )   {    \$hms = "";    \$hours = intval( intval( \$sec ) / 3600 );     \$hms .= ( \$padHours )           ? str_pad( \$hours, 2, "0", STR_PAD_LEFT ). ':'          : \$hours. ':';    \$minutes = intval( ( \$sec / 60 ) % 60 );     \$hms .= str_pad( \$minutes, 2, "0", STR_PAD_LEFT ). ':';    \$seconds = intval( \$sec % 60 );     \$hms .= str_pad( \$seconds, 2, "0", STR_PAD_LEFT );    return \$hms;  }if ( \$_POST["minutes"] or \$_POST["seconds"] )  {    \$myFilter = new InputFilter( \$tags, \$attr, \$tag_method, \$attr_method, \$xss_auto );    \$minutes = \$myFilter->process( \$_POST["minutes"] );    \$seconds = \$myFilter->process( \$_POST["seconds"] );    \$goodpoint = 0.6180339887 * ( \$seconds + ( \$minutes * 60 ) );    \$answer = sec2hms( \$goodpoint );  }?><html> <head>  <meta http-equiv="content-type" content="text/html; charset=UTF-8">  <title>   Golden Calculator  </title> </head> <body>  <form action="golden.php" method="post">   <p>    Min: <input type="text" name="minutes" />    Sec: <input type="text" name="seconds" />    <input type="submit" />   </p>  </form>  <p>   Answer: <strong><?php echo \$answer; ?></strong>  </p> </body></html>` Subscribe to comments