Okay, I've already done a nice little code to translate a floating number into a minute-and-second format to calculate paces for running races. Now, I need to make this a function. To be honest, I have no idea how to write the function and was wondering if someone could help. Here's the basic code:
<?php
//*Define variables
$distance="distance";
$d=26.21865;
$h=10;
$m=31;
$s=14.22;
$t=$h*3600+$m*60+$s;
$pace=$t/$d;
//*Set up concatenation
$pm = intval ($pace/60);
$sc = $pace/60; //*sc=Second Converter
$sc1 = (($sc-$pm)*60); //*sc1=Second Converter 1
$ps = number_format($sc1, 2, ".", ","); //*ps=Pace (in seconds)
?>
<?php
if ($ps<10)
{
print("Your time for the "." ".$distance." "."is: ".$h.":".$m.":".$s.".<br>");
print("Your pace is: ".$pm.":0".$ps.".");
}
elseif ($ps>=10)
{
print("Your time for the "." ".$distance." "."is: ".$h.":".$m.":".$s.".<br>");
print("Your pace is: ".$pm.":".$ps.".");
}
?>
Now, I know how the function is supposed to work...in theory.
<?php function pace() {...
But, that's where I get lost. Am I supposed to identify an argument, then run the code with the new argument values?