Re: [PHP] count up from 7
Richard -- ...and then Richard Whitney said... % % Braindead! Hey, who are you callin' names?!? % % I need to evaluate a number if greater than 7 and add a value per increment. Greater than seven is easy. Adding a value is easy. Per increment can be a little tricky but we'll assume for the moment that the window is 1. The code $sum = 67 ; # starting value $trg = 7 ;# trigger value $add = 6 ;# what we add each time $num = 10 ; # what we're evaluating (hardcoded here!) for ( $num ; $trg $num ; $trg++ ) { $sum += $add ; } print when num = $num, sum = $sum\n ; should do for a starting point, though, and produces bash-2.05a$ php -q /tmp/inc.php when num = 10, sum = 85 bash-2.05a$ php -q /tmp/inc.php when num = 20, sum = 145 bash-2.05a$ php -q /tmp/inc.php when num = 7, sum = 67 bash-2.05a$ php -q /tmp/inc.php when num = 1, sum = 67 when run. Extra credit if you write it as a recursive function :-) % I'm frazzled and can't think straight. You can't ask straight, either :-) Give us more details! % % Thanks Guys! HTH HAND :-D -- David T-G * There is too much animal courage in (play) [EMAIL PROTECTED] * society and not sufficient moral courage. (work) [EMAIL PROTECTED] -- Mary Baker Eddy, Science and Health http://justpickone.org/davidtg/ Shpx gur Pbzzhavpngvbaf Qrprapl Npg! pgp0.pgp Description: PGP signature
[PHP] count up from 7
Braindead! I need to evaluate a number if greater than 7 and add a value per increment. I'm frazzled and can't think straight. Thanks Guys! -- Richard Whitney * Transcend Development Producing the next phase of your internet presence. [EMAIL PROTECTED] * http://xend.net* 602-971-2791 * * * * * *__** _/ \___ * * / *\** */ * * \ **/\_ |\ / \_ / \ / \/\ / \ /\ / \ -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] count up from 7
Huh? Not really following what you want to achieve, but: ? $n = 9; $floor = 7; if($n $floor) { $diff = $n - $floor; //eg 2 // no idea what you want to do from here } ? on 25/03/03 10:58 AM, Richard Whitney ([EMAIL PROTECTED]) wrote: Braindead! I need to evaluate a number if greater than 7 and add a value per increment. I'm frazzled and can't think straight. Thanks Guys! -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] count up from 7
not sure if this is what you're looking for: if ( $var 7 ) { // do stuff } - cheers, Sebastian - Original Message - From: Richard Whitney [EMAIL PROTECTED] | Braindead! | | I need to evaluate a number if greater than 7 and add a value per increment. | I'm frazzled and can't think straight. | | Thanks Guys! -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php