Lessur Posted July 28, 2006 Share Posted July 28, 2006 I want to be able to say, if $blah == even { echo "";).How can I tell it what even is (like a even number)? Link to comment https://forums.phpfreaks.com/topic/15898-even-and-odd/ Share on other sites More sharing options...
Ninjakreborn Posted July 28, 2006 Share Posted July 28, 2006 not possible, I don't think a built in function does that, only idea, is auto increment by 2, in an array. I guess like for 0 - odd number's start at 1auto increment it +2, for each and every array entryit'll be1357911and set a maximum like 500 for the maximum that should handle most of your needsthen create another array auto increment it by +2 which I think is++++++ is auto incrementthen run the array through thatuntil a max 500so it would be246810and so forth, then pull out some regex's and start working with creating a variable to test it against the array, somehow and try to figure out whether it matched the array on an even number or on a odd number, that's a theory to run with atleast. Link to comment https://forums.phpfreaks.com/topic/15898-even-and-odd/#findComment-65224 Share on other sites More sharing options...
effigy Posted July 28, 2006 Share Posted July 28, 2006 [url=http://us3.php.net/operators.arithmetic]Modulus Operator[/url].[code]<?php $tests = range(1, 10); foreach ($tests as $test) { echo "$test: ", ($test % 2 ? 'Odd' : 'Even'), '<br />'; }?>[/code] Link to comment https://forums.phpfreaks.com/topic/15898-even-and-odd/#findComment-65250 Share on other sites More sharing options...
Ninjakreborn Posted July 28, 2006 Share Posted July 28, 2006 ah, good idea Link to comment https://forums.phpfreaks.com/topic/15898-even-and-odd/#findComment-65473 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.