Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations wOOdy-Soft on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Variable Check

Status
Not open for further replies.

rjseals

Technical User
Nov 25, 2002
63
US
What would be a good way to varify that a php variable contains either all letters or all numbers. Is it possible? I am kind of thinking of something similar to the NaN function in Javascript.

Thanks
 
regular expressions is a good way

_____________________________________________________________________
onpnt2.gif

The answer to your ??'s may be closer then you think.
Check out Tek-Tips knowledge bank by clicking the FAQ link at the top of the page
 
Can you give one small example?

Thanks
 
sure
reference:

here's the example shown from the php manual. the link will give you about all te information you'll need to get your own built for the specific needs.

<?php
// The &quot;i&quot; after the pattern delimiter indicates a case-insensitive search
if (preg_match(&quot;/php/i&quot;, &quot;PHP is the web scripting language of choice.&quot;)) {
echo &quot;A match was found.&quot;;
} else {
echo &quot;A match was not found.&quot;;
}
?>

although this is a javascript tutorial, the nice thing about regular expressions patterns is they are pretty much universal as far as patterns go. so numeric match being \d in javascript, vbscript, python and php is nonchanging


_____________________________________________________________________
onpnt2.gif

The answer to your ??'s may be closer then you think.
Check out Tek-Tips knowledge bank by clicking the FAQ link at the top of the page
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top