Search the Community
Showing results for tags 'madlib'.
-
Can anyone help me? I am a student and I have been working on a PHP project for over two weeks with no luck on one piece of code. The project is a small "Madlib" project, but I'm only having trouble with one piece of code. Any takers? All I'm trying to do is get a sentence like "I bought a NOUN and NOUN." to be replaced with "I bought a cat and a dog." The problem is, I get this: "I bought a cat and a cat." I have tried all the loops I can try. Yes, I'm a newbie, but I'm desperate and can't figure this out. I have my html and php code, also the URL to the website. Any help would greatly be appreciated. Thanks. I have attached my html and my php file to this posting. project1.htmlproject1.php I have posted the small piece of code I am having a problem with down below: $counter=0; $nounCounter=0; while ( $counter < $sentLength and $nounCounter < $nounLength) { if($sentArray[$counter]=="NOUN") { $newSent = str_replace($sentArray[$counter], $nounArray[$nounCounter], $initialSent); } $counter++; echo $newSent . '<br .>';