Page 1 of 1
Legible word generator
Posted: 11 Jun 2006, 20:03
by Gogeta70
Hey guys, it's been forever since i've coded something, so i decided to make this. Tell me what you guys think...
Taking suggestions!
Source
Posted: 11 Jun 2006, 20:28
by Nerdz
usrname and pws required.
Posted: 11 Jun 2006, 22:17
by Gogeta70
Oops, sorry.
user: beta
pass: tester
By the way, you can see it in action here:
Link
Posted: 12 Jun 2006, 06:54
by FrankB
Congratulations.
There is no more to add.
Maybe, there's a shortcut for the arrays but i am not sure, at eye-view, just like that i cannot tell but here's the hint : multidimensional arrays.
Now, i cannot see immediately how you could force that through your code but still, it is a very good exercise and an example for many.
--
FrankB
Posted: 12 Jun 2006, 12:37
by Nerdz
Code: Select all
if(strlen($word) == $amt)
{
$finished = TRUE;
}
else
{
$finished = FALSE;
}
I don't know anything about php but if it works, I think this would be better:
Code: Select all
$finished = (strlen($word) == $amt);
I guess $finished is a bool and the condition return a bool to
I keep looking at the code... why don't u use this condition in the FOR? strlen($word) == $amt ... If WHILE exist in this case it would be more appropriate
Posted: 12 Jun 2006, 18:52
by Gogeta70
Well nerdz, it'd been about 3 or 4 months since i've coded something in PHP.
That line of code suggested would not work.
Code: Select all
for($finished = FALSE; $finished != TRUE;) //if the word length is > 8 characters, $ finished = false;
{
$tmp1 = count($letters[$last]['ok']) -1; //blah
$tmp2 = rand(0, $tmp1); // blah
$word .= $letters[$last]['ok'][$tmp2]; // blah
$last = $letters[$last]['ok'][$tmp2]; // blah
if(strlen($word) == $amt) // if $word is equal to 8 characters (specified in $amt, then $finished is true, else $finished is false.
{
$finished = TRUE;
}
else
{
$finished = FALSE;
}
}
That's what that part of code means.
Posted: 12 Jun 2006, 20:31
by Nerdz
I know what the code is doing... but i tought it would like other programming language where
Code: Select all
bool b;
while ( b == true)
{
if ( conditionA)
b = true;
else
b = false;
}
is the same as:
Code: Select all
while (conditionA)
{
//do your code...
}
Sry maybe i'm a bit confuse
Posted: 12 Jun 2006, 21:41
by Gogeta70
Well i would include the if statement in the for, however it's got to set a variable depending on data, which takes more than 1 line of code.
for(set the variable; (the if); (the then))
{}
WHOA, i just kinda corrected myself. Now i see where you're coming from. I could do this:
Code: Select all
while(strlen($word) != $amt)
{
do code
}
Thanks for the heads up, nerdz.
Posted: 13 Jun 2006, 09:34
by Nerdz
No problem