Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 3 of 3

Thread: Variable help?

  1. #1
    AJM
    AJM is offline
    New Coder
    Join Date
    Nov 2011
    Location
    USA
    Posts
    21
    Thanks
    1
    Thanked 1 Time in 1 Post

    Variable help?

    First of all, excuse my stupid question, but is it possible to do something like this:
    PHP Code:
    if($var1 == '$'.anychars)
      print 
    "the variable had a $ in it";
    else
      print 
    "the var didnt have a $ in it"
    anychars would be any ASCII character...

    Any help will be appreciated, and I can expand if needed.

    Thanks,

    -AJM

  • #2
    Regular Coder
    Join Date
    Jul 2010
    Location
    Oregon City
    Posts
    280
    Thanks
    5
    Thanked 50 Times in 49 Posts
    Quote Originally Posted by AJM View Post
    First of all, excuse my stupid question, but is it possible to do something like this:
    PHP Code:
    if($var1 == '$'.anychars)
      print 
    "the variable had a $ in it";
    else
      print 
    "the var didnt have a $ in it"
    anychars would be any ASCII character...

    Any help will be appreciated, and I can expand if needed.

    Thanks,

    -AJM

    If you have something..

    PHP Code:
    $var1 '$var1';
    $var2 '$var2';

    echo 
    strpos($var1'$'); // returns 0 
    then ya.. but as far as i kno its not actually possible to do what you're asking but i could be wrong.

  • #3
    AJM
    AJM is offline
    New Coder
    Join Date
    Nov 2011
    Location
    USA
    Posts
    21
    Thanks
    1
    Thanked 1 Time in 1 Post
    preg_match() did the trick. Thanks for the reply.


    -AJM


  •  

    Tags for this Thread

    Posting Permissions

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