Jump to content

Ignore case


Michdd

Recommended Posts

I do not know in what context you want to match that, but you can use the function below.

 

 if (strtolower("Name") == "name") {echo "It matches!";}

 

For it to work now the first letter of the actual name must be upper case. Otherwise it doesn't find the name, is there a way that I can make it so that even if the first letter they put in isn't capital, it will still find the name?

Link to comment
Share on other sites

For it to work now the first letter of the actual name must be upper case. Otherwise it doesn't find the name, is there a way that I can make it so that even if the first letter they put in isn't capital, it will still find the name?

 

I don't understand, can I see your code?

Link to comment
Share on other sites

For it to work now the first letter of the actual name must be upper case. Otherwise it doesn't find the name, is there a way that I can make it so that even if the first letter they put in isn't capital, it will still find the name?

 

ucfirst(strtolower("Name"));

Link to comment
Share on other sites

For it to work now the first letter of the actual name must be upper case. Otherwise it doesn't find the name, is there a way that I can make it so that even if the first letter they put in isn't capital, it will still find the name?

 

I don't understand, can I see your code?

 

<?php

$name = $_REQUEST['name'];

$content = file_get_contents('http://toptfg.wise-projects.com/list.txt');

$online = strpos($content, $name);


$im = imagecreate(100, 30);


$bg = imagecolorallocate($im, 255, 255, 255);
$textcolor = imagecolorallocate($im, 0, 255, 0);
$textcolor1 = imagecolorallocate($im, 255, 0, 0);



if( $online === false ) {

imagestring($im, 5, 0, 0, 'Offline!', $textcolor1);

} else {

imagestring($im, 5, 0, 0, 'Online!', $textcolor);

}


header('Content-type: image/png');

imagepng($im);
imagedestroy($im);
?>

 

Now on the list that it's using file_get_contents on the names all start with Capitals, then it uses strpos to search that list, and then outputs a Online, or Offline image, depending if they're on that list or not. But if someone enters online.php?name=example and "Example" is online, it still still say it's offline, because it's not capital, I don't want it to do this.

Link to comment
Share on other sites

Just had a look at the actual list. You should explode() it, and use in_array() to search for the user:

 

<?php
$name = $_REQUEST['name'];

$content = file_get_contents('http://toptfg.wise-projects.com/list.txt');

$names = explode('<BR>', $content);
array_shift($names);
array_pop($names);

$online = in_array($name, $names);
?>

Link to comment
Share on other sites

Sorry, forgot your initial problem :) This should work:

 

<?php
$name = $_REQUEST['name'];

$content = file_get_contents('http://toptfg.wise-projects.com/list.txt');

$names = explode('<BR>', $content);
array_shift($names);
array_pop($names);

$online = in_array(ucfirst(strtolower($name)), $names);
?>

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.