Go Back   CodingForums.com > :: Server side development > PHP

Before you post, read our: Rules & Posting Guidelines

Reply
 
Thread Tools Rate Thread
Enjoy an ad free experience by logging in. Not a member yet? Register.
Old 11-26-2011, 10:52 PM   PM User | #1
AJM
New Coder

 
Join Date: Nov 2011
Location: USA
Posts: 21
Thanks: 1
Thanked 1 Time in 1 Post
AJM is an unknown quantity at this point
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
AJM is offline   Reply With Quote
Old 11-27-2011, 12:25 AM   PM User | #2
Adee
Regular Coder

 
Join Date: Jul 2010
Location: Oregon City
Posts: 280
Thanks: 5
Thanked 50 Times in 49 Posts
Adee can only hope to improve
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.
Adee is offline   Reply With Quote
Old 11-27-2011, 01:08 AM   PM User | #3
AJM
New Coder

 
Join Date: Nov 2011
Location: USA
Posts: 21
Thanks: 1
Thanked 1 Time in 1 Post
AJM is an unknown quantity at this point
preg_match() did the trick. Thanks for the reply.


-AJM
AJM is offline   Reply With Quote
Reply

Bookmarks

Tags
ascii chars, rand, variable

Jump To Top of Thread


Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT +1. The time now is 09:52 AM.


Advertisement
Log in to turn off these ads.