Click to See Complete Forum and Search --> : differentiate CAPS & small variables?


hammerslane
11-03-2003, 09:07 AM
hello there.

i'm passing a variable from two different pages, (1.php and 2.php, called $client) through to final.php.

both 1.php and 2.php have drop down boxes, with the same client data (for example...
<option value=OURTHIRDCLIENT> OURTHIRDCLIENT </option>
the only difference between 1.php's drop down box and 2.php's drop down box, is that all of 2.php's values are in small caps.

on final.php, i want to run an if statement to detect firstly, if the contents of the $client is in caps lock or not, then based on that outcome, do other actions, which to this example aren't necessary to tell you.

is there a caps lock detect function?

thankyou very much

regards

PunkSktBrdr01
11-03-2003, 09:29 AM
Check the strings (http://us2.php.net/manual/en/ref.strings.php) section of the PHP fuction reference. If you don't see anything there, you may need to use preg_match() (http://us2.php.net/manual/en/function.preg-match.php). Hope that helps!

pyro
11-03-2003, 09:57 AM
Perhaps strtoupper() (http://us3.php.net/manual/en/function.strtoupper.php) and strtolower() (http://us3.php.net/manual/en/function.strtolower.php)?

hammerslane
11-03-2003, 10:40 AM
ok i've spent about an hour looking through all php.net's related functions, aswell as the one you both gave me, but i don't really have the expertise to put them into practice. the strcasecmp (http://us2.php.net/manual/en/function.strcasecmp.php) function returns 0 or 1 depending on if two variables are the same, ignoring case sensitivity.

i still can't find a function which can be adapted to what i want to do. :(
pyro... the ones you gave me, do they just change variable cases? because i dont want to change the case of the variable, just to detect the caps/small case attribute of the variable.
pp#50

pyro
11-03-2003, 11:07 AM
Yes, that is what they do, but they should be useful in this case:

<?PHP

$foo = "blah";
if ($foo == strtoupper($foo)) {
echo '$foo ('.$foo.') is uppercase.';
}
else {
echo '$foo ('.$foo.') is lowercase.';
}

?>

hammerslane
11-04-2003, 03:22 AM
thanks pyro, and PunkSktBrdr. got the if statement working :cool:

pyro
11-04-2003, 07:13 AM
Sure thing... :)