I've been working on a project for school where I have you search for a string, and it wil query a database and return all of the words which are in that string of letters. For that, I have to use strtoupper(), which works fine if you have a string of all uppercase or lowercase letters. If you enter AAB or aab into the search, everything will work fine, and it will return the two anagrams, ABA and BAA. However, if you type in aAB, it will return nothing.
So it is getting the post data from the input, named alpha, and then it is alphabetizing the word, so if you typed in ABA, it would return AAB, and then making it uppercase.
<title>Scrabble</title>
<?php
require 'connect.inc.php';
if (isset($_POST['al'])){
$al=$_POST['al'];
$al=alpha($al);
$al=trim(strtoupper($al));
$query="SELECT * from Words WHERE alpha='$al'";
if ($query_run = mysql_query($query)){
while ($query_row = mysql_fetch_assoc($query_run)){
$alpha = $query_row['alpha'];
$ana = $query_row['word'];
echo "<strong>$ana</strong> $alpha<br>";
}
}
}
function alpha($word){
$array=array();
for($x=0;$x<strlen($word);$x++){
$char=substr($word,$x,1);
$array[$x]=$char;
}
sort($array);
$alpha=implode('',$array);
return $alpha;
}
?>
<form action='scrabble.php' method='POST'>
Enter text to anagram. Please use either all uppercase or all lowercase<input type='text' name='al'>
<input type='submit'>
</form>
he link is here http://newdev.shodor.org/~amalani/newdev/scrabble.php Thanks