Hello again
i m trying to create my first function but seems that i forgot something.
the $enddate is a variable i use in index.php and i m trying to use it in my function
<?php
function cntdwn(global ,$enddate) {
$year = substr($enddate,0,4);
$month = substr($enddate,4,2);
$day = substr($enddate,6,2);
$hour = substr($enddate,8,2);
$minute = substr($enddate,10,2);
$second = substr($enddate,12,2);
// time in seconds between now and then
$secdiff = mktime($hour,$minute,$second,$month,$day,$year) - time();
$a = floor ($secdiff/86400); // number of days
$b = floor ($secdiff%86400/3600); // + number of hours
$c = floor ($secdiff%86400%3600/60); // + number of minutes
$d = floor ($secdiff%86400%3600%60); // + number of seconds
// define extra text
$text1 = " Still "; $text2 = " d "; $text3 = " h ";
$text4 = " m "; $text5 = " and "; $text6 = " s "; $text7 = " to go! ";
// change displayed text and numbers to get the grammar right
// and avoid to display "0" days, hours etc.
if ($a < 2) $text2 = " day ";
if ($a < 1) $a = " " . $text2 = " ";
if ($b < 2) $text3 = " hour ";
if ($b < 1) $b = " " . $text3 = " ";
if ($c < 2) $text4 = " minute ";
if ($c < 1) $c = " " . $text4 = " ";
if ($d < 2) $text6 = " second ";
if ($d < 1) $d = " " . $text6 = " ";
if ($d == 0) $text5 = " ";
// the countdown message
if ($secdiff > 0) return $result = "($text1 $a $text2 $b $text3 $c $text4 $text5 $d $text6 $text7)";
//after countdown is up this message will be displayed
else $result = "Finished. ";
return($result);
}
?>
this i name it cntdwn.inc.php
in my index is v set
include("cntdwn.inc.php");
and later in my code
$countdown = cntdwn($enddate);
i use it this way cause want to display the result of my function
later.
what i m doing wrong???