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
Legible word generator
Legible word generator
Last edited by Gogeta70 on 11 Jun 2006, 22:18, edited 1 time in total.
¯\_(ツ)_/¯ It works on my machine...
- FrankB
- Ph. D. in Sucko'logics
- Posts: 315
- Joined: 06 Mar 2006, 17:00
- 18
- Location: Belgistahn
- Contact:
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
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
- Nerdz
- The Architect
- Posts: 1127
- Joined: 15 Jun 2005, 16:00
- 19
- Location: #db_error in: select usr.location from sucko_member where usr.id=63;
- Contact:
Code: Select all
if(strlen($word) == $amt)
{
$finished = TRUE;
}
else
{
$finished = FALSE;
}
Code: Select all
$finished = (strlen($word) == $amt);
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
Give a man a fish, you feed him for one day.
Learn a man to fish, you feed him for life.
Learn a man to fish, you feed him for life.
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.
That's what that part of code means.
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;
}
}
¯\_(ツ)_/¯ It works on my machine...
- Nerdz
- The Architect
- Posts: 1127
- Joined: 15 Jun 2005, 16:00
- 19
- Location: #db_error in: select usr.location from sucko_member where usr.id=63;
- Contact:
I know what the code is doing... but i tought it would like other programming language where
is the same as:
Sry maybe i'm a bit confuse
Code: Select all
bool b;
while ( b == true)
{
if ( conditionA)
b = true;
else
b = false;
}
Code: Select all
while (conditionA)
{
//do your code...
}
Give a man a fish, you feed him for one day.
Learn a man to fish, you feed him for life.
Learn a man to fish, you feed him for life.
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:
Thanks for the heads up, nerdz.
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
}
Last edited by Gogeta70 on 13 Jun 2006, 18:08, edited 1 time in total.
¯\_(ツ)_/¯ It works on my machine...