Millar Posted August 5, 2006 Share Posted August 5, 2006 I have made a recursive function - function croncount ( $sec, $count ) { if ( $sec > 299 ) { $count = $count + 1; $sofar = $count * 300; $poo = $sec - $sofar; croncount ( $poo, $count ); } else { return "$count"; }} It is supposed to work out how many lots of 300 there are in the number ($sec).But when I print out this function, nothing is returned?What have I done wrong?I set $count to "0" when calling the function, so it starts from "0".EDIT: Nevermind just found the problem, I wasn't returning the function in the first IF bit. Link to comment Share on other sites More sharing options...
murfitUK Posted August 5, 2006 Share Posted August 5, 2006 Would it not be easier to divide by 300 and find the integer value:$number = intval ($sec/300);$number will then give you the number of complete 300s within the value of $sec. Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now