I just do not know where my error is occuring or why teh script doesn't work but I thought maybe somone who's had sleep in teh past 16 hours might be able to spot it out.
There's a form, you input words. You can seperate them with commas and then count the number of unique words (Or spaces I could have done spaces) or you can see how many premutations (letter combos) each one has. Letter combos worked fine but unique word counting failed miserably.
<?php
if(isset($_POST['action'])){
if($_POST['action'] == "preM"){
if(isset($_POST['msg'])){
$string = $_POST['msg'];
$characters = strlen($string);
$char= $characters-1;
while($char>0)
{
$characters = $characters*($char);
//echo("$char\n");
//echo("........".$characters."\n");
$char = ($char-1) ;
}
echo("There are $characters Different Combinations of the letters in '$msg' ");
echo("<br>Premutations: $characters ");
$characters1 = $characters/6;
echo("<br>3 letter combos: $characters1 ");
}
}elseif($_POST['action'] =="Grade"){
if(!empty($_POST['msg'])){
$message = $_POST['msg'];
$array = explode(",",$message);
$container = array("test");
$ii = 0;
$loops = count($array);
while($ii<$loops){
$word = $array[$ii];
if(!preg_match("/$word/i","$container")){
$container[$ii] = $word;
$ii++;
}
}
}
}
}
if(isset($container)){
$iii = 0;
$size = count($container);
while($iii>$size){
$echo = $container[$iii];
echo("$echo\n");
$iii++;
}
}
//echo($size);
?>
<form action="<?echo($_SERVER['PHP_SELF']);?>" method='post'>
<table align='center' border='2' bordercolor='black'>
<tr><td>
<textarea cols='50' rows='9' name='msg'>
WORDS
</textarea>
</td></tr>
<tr><td>
<input type='radio' name='action' value='Grade'>Show Unique Strings<br>
<input type='radio' name = 'action' value='preM'>Show Premutation Info
</td></tr>
<tr><td>
<input type='submit' value='GO!'>
</td></tr>
</table>
</form>
while($iii>$size){
$echo = $container[$iii];
echo("$echo\n");
$iii++;
}
as long as $iii is greater than $size to begin with, it'll keep going and going and going
Quote from: dest on February 24, 2006, 01:25:57 AM
while($iii>$size){
$echo = $container[$iii];
echo("$echo\n");
$iii++;
}
as long as $iii is greater than $size to begin with, it'll keep going and going and going
but . . . .$iii was smaller than $size, it always is because $iii is Zero and size is never less than 1. ? ? ? ?
Although you did find the error, it should say $iii<$size. Thanks... maybe I can fix it.