Anyone know how to do this?

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
DynamiteHost
Forum Commoner
Posts: 69
Joined: Sat Aug 10, 2002 5:33 pm

Anyone know how to do this?

Post by DynamiteHost »

Any ideas?

I just need to know how to do the "if ($something is between 1 and 10)" part.

===============

Code: Select all

$something = 3;

if ($something is between 1 and 10) {
DO THIS
}
else {
DO THIS
}
User avatar
hob_goblin
Forum Regular
Posts: 978
Joined: Sun Apr 28, 2002 9:53 pm
Contact:

Post by hob_goblin »

Code: Select all

if ($something >= 1 || $something <= 10) &#123; 
// do this
&#125; 
else &#123; 
// do this
&#125;
User avatar
llimllib
Moderator
Posts: 466
Joined: Mon Jul 01, 2002 2:19 pm
Location: Baltimore, MD

Post by llimllib »

Code: Select all

if ($something >= 1 && $something <= 10) &#123;
// do this
&#125;
else &#123;
// do this
&#125;
To be technical, you want the && (and) not the || (or) symbol between those.
DynamiteHost
Forum Commoner
Posts: 69
Joined: Sat Aug 10, 2002 5:33 pm

Post by DynamiteHost »

Thanks for the help you two, its appreciated :)
User avatar
m3mn0n
PHP Evangelist
Posts: 3548
Joined: Tue Aug 13, 2002 3:35 pm
Location: Calgary, Canada

Post by m3mn0n »

very much so! ;)
User avatar
hob_goblin
Forum Regular
Posts: 978
Joined: Sun Apr 28, 2002 9:53 pm
Contact:

Post by hob_goblin »

ahh my brain wasnt working that late, i had the right idea though
Post Reply