PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!
Moderator: General Moderators
d3ad1ysp0rk
Forum Donator
Posts: 1661 Joined: Mon Oct 20, 2003 8:31 pm
Location: Maine, USA
Post
by d3ad1ysp0rk » Tue Oct 21, 2003 9:28 pm
I know theres a way, but I've never been good at finding things in the php manuel..
Is there a way to make something non case sensitive, ie:
Code: Select all
<?php
if($user=="Josh")
{
echo "Hi Josh.";
}
?>
still works whether $user is "Josh" or "joSH"
Thanks in advance.
markl999
DevNet Resident
Posts: 1972 Joined: Thu Oct 16, 2003 5:49 pm
Location: Manchester (UK)
Post
by markl999 » Tue Oct 21, 2003 9:37 pm
Code: Select all
if(!strcmp(strtolower($user), strtolower('Josh')){
echo 'Hi, Josh.';
Kriek
Forum Contributor
Posts: 238 Joined: Wed May 29, 2002 3:46 am
Location: Florida
Contact:
Post
by Kriek » Wed Oct 22, 2003 12:44 am
LiLpunkSkateR wrote: non case sensitive
You mean case-insensitive.
Code: Select all
<?php
if(stristr($user, 'Josh')) {
echo 'Hi Josh';
}
?>
See -> the
stristr() function.
devork
Forum Contributor
Posts: 213 Joined: Fri Aug 08, 2003 6:44 am
Location: p(h) developer's network
Post
by devork » Wed Oct 22, 2003 2:22 am
also
if($user=='Josh') has difference with if ($user=="josh")
Cruzado_Mainfrm
Forum Contributor
Posts: 346 Joined: Sun Jun 15, 2003 11:22 pm
Location: Miami, FL
Post
by Cruzado_Mainfrm » Wed Oct 22, 2003 4:16 pm
try POSIX regex function
Code: Select all
<?php
$inputname = "John";
$storedname = "john";
if (eregi("^".$inputname."$",$storedname)) {
echo "Input name matches stored one.";
} else {
echo "Input name mismatches stored one.";
}
?>
DuFF
Forum Contributor
Posts: 495 Joined: Tue Jun 24, 2003 7:49 pm
Location: USA
Post
by DuFF » Wed Oct 22, 2003 5:49 pm
Heres what I do:
Make the username string lowercase (database name is also lowercase)
Compare the username string to the database name
Store the inputted username in a session
Output the session data, which is saved how they spelt it.