SitePoint Sponsor

User Tag List

Results 1 to 3 of 3
  1. #1
    SitePoint Wizard
    Join Date
    Jan 2005
    Location
    blahblahblah
    Posts
    1,447
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    a function to check if a number is in a range?

    hello,
    is there a function that could check if a given number is in a range of other numbers?
    Something like:

    PHP Code:
    $number 43;

    if (
    in_range(25-50$number)){
        
    //do something

    Does such a function exists?


  2. #2
    *munch munch* killerkooki's Avatar
    Join Date
    Sep 2004
    Location
    Singapore
    Posts
    405
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    None that I am aware of.

    PHP Code:
    function inRange($valueToCheck$lowerLimit$upperLimit) {
    if (
    $valueToCheck >= $lowerLimit && $valueToCheck <= $upperLimit)
        return 
    true;
    else
        return 
    false;

    Something like that should be sufficient I assume.

  3. #3
    SitePoint Wizard
    Join Date
    Jan 2005
    Location
    blahblahblah
    Posts
    1,447
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    hey thanks


Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •