#1
  1. No Profile Picture
    Junior Member
    Devshed Newbie (0 - 499 posts)

    Join Date
    Jul 2000
    Posts
    21
    Rep Power
    0
    hello again

    Let us say that i have 3 variables:

    $1, $2, $3

    Now i want to check if those variables contain any data. i would like to do that with an "IF", but i dont want to write if for each variable, i want to take them in one sweap instead:

    For example:
    1.
    if($1 $2 $3 == "")
    {
    print "No data in here";
    }

    2.
    if($1 and $2 and $3 == "")
    {
    print "No data in here";
    }

    3.
    if($1,$2,$3 == "")
    {
    print "No data in here";
    }
    -----------------------------------------
    I dont think any of those 3 alternatives works so i would be very happy for some sugestions

    Maybe create an array for those 3 vars?
    ps! i know there is no "else" up there in the code...thats ok

    Thx
  2. #2
  3. No Profile Picture
    Contributing User
    Devshed Novice (500 - 999 posts)

    Join Date
    Jul 2000
    Posts
    669
    Rep Power
    15
    if (($1 == "") | | ($2 == "") | | ($3 == "")) {

    print "missing data";

    }
  4. #3
  5. No Profile Picture
    Junior Member
    Devshed Newbie (0 - 499 posts)

    Join Date
    Jul 2000
    Posts
    21
    Rep Power
    0
    Hehehehe i was about to reply to this topic that i found a solution but THANK YOU anyway for the reply

    I wrote it like this:

    if ($1 == "" && $2 == "" && $3 == "")

    Best Regards
    od
  6. #4
  7. No Profile Picture
    Contributing User
    Devshed Novice (500 - 999 posts)

    Join Date
    Jul 2000
    Posts
    669
    Rep Power
    15
    Keep in mind that if you use your way and two of the variables have values and one doesn't it will return false.
  8. #5
  9. No Profile Picture
    Contributing User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Jun 2000
    Posts
    43
    Rep Power
    15
    How bout:

    if(!($1 | | $2 | | $3)) {
    print("No data here.");
    }

    ------------------
    webpatron.com

Similar Threads

  1. Passing POST variables
    By rlorenzo in forum PHP Development
    Replies: 11
    Last Post: June 6th, 2004, 03:00 PM
  2. help with assigning variables, variable passing/ retrieval
    By pinkipodmini in forum PHP Development
    Replies: 0
    Last Post: February 13th, 2004, 10:40 PM
  3. Replies: 2
    Last Post: February 11th, 2004, 12:03 AM
  4. functions and variables
    By uniopp in forum PHP Development
    Replies: 7
    Last Post: September 25th, 2003, 10:43 AM
  5. Automatically creating class variables
    By dreamstring in forum PHP Development
    Replies: 1
    Last Post: August 15th, 2003, 10:12 AM

IMN logo majestic logo threadwatch logo seochat tools logo