soulscratch
May 9th 2007, 12:06 am
Example:
$bulls = array(
'Michael Jordan',
'Scottie Pippen',
'Dennis Rodman',
'Tony Kukoc',
'Luc Longley'
);
Now, I have a form that asks the user to enter the name of a player, to see if that player (or string) is in this team (or array).
Let's say I clicked submit, and $_POST['player-name'] is equal to 'michael jordan'.
// the submit input has a name attribute equal to submitted
if (isset($_POST['submitted'])) {
if(isset($_POST['player-name'] && !empty($_POST['player-name']) {
$player = $_POST['player-name'];
if(in_array($player, $bulls)) {
echo $player . ' ' . 'is in the Bulls.';
} else {
echo $player . ' ' . 'is <strong>not</strong> in the Bulls.';
}
}
}
(i may have screwed up on the end brackets, sorry for that).
This will check if the value of the $player variable is inside the $bulls array, but how can I make it so that it converts the $player variable to lowercase and every value in $bulls to lowercase, so that capitalized letters wont matter?
Thanks in advance.
$bulls = array(
'Michael Jordan',
'Scottie Pippen',
'Dennis Rodman',
'Tony Kukoc',
'Luc Longley'
);
Now, I have a form that asks the user to enter the name of a player, to see if that player (or string) is in this team (or array).
Let's say I clicked submit, and $_POST['player-name'] is equal to 'michael jordan'.
// the submit input has a name attribute equal to submitted
if (isset($_POST['submitted'])) {
if(isset($_POST['player-name'] && !empty($_POST['player-name']) {
$player = $_POST['player-name'];
if(in_array($player, $bulls)) {
echo $player . ' ' . 'is in the Bulls.';
} else {
echo $player . ' ' . 'is <strong>not</strong> in the Bulls.';
}
}
}
(i may have screwed up on the end brackets, sorry for that).
This will check if the value of the $player variable is inside the $bulls array, but how can I make it so that it converts the $player variable to lowercase and every value in $bulls to lowercase, so that capitalized letters wont matter?
Thanks in advance.