Can somebody post a little php snippet for this?
I have a textfile like this:
I {love|like|need} {coffee|tea}.
He is {cool|nice|awesome} {.|..|!}
Are you {hungry|tired|angry}?
The little php snippet should select one line of the textfile at random and create a random sentence from it, every time i start the php-script.
Example:
After starting the script, it selects line 1: "I {love|like|need} {coffee|tea}."
Then it creates a random sentence like "I like tea." or "I love coffee." (or something like this) from it.
Random Sentences - Question
Moderator: General Moderators
- AbraCadaver
- DevNet Master
- Posts: 2572
- Joined: Mon Feb 24, 2003 10:12 am
- Location: The Republic of Texas
- Contact:
Re: Random Sentences - Question
What have you tried that's not working?
mysql_function(): WARNING: This extension is deprecated as of PHP 5.5.0, and will be removed in the future. Instead, the MySQLi or PDO_MySQLextension should be used. See also MySQL: choosing an API guide and related FAQ for more information.
Re: Random Sentences - Question
I don't know where to start. My php knowledge is not big enough right now. But from such a snippet i could learn more.
- AbraCadaver
- DevNet Master
- Posts: 2572
- Joined: Mon Feb 24, 2003 10:12 am
- Location: The Republic of Texas
- Contact:
Re: Random Sentences - Question
I would start with file() and shuffle(), then preg_match() and explode().peterhere wrote:I don't know where to start. My php knowledge is not big enough right now. But from such a snippet i could learn more.
mysql_function(): WARNING: This extension is deprecated as of PHP 5.5.0, and will be removed in the future. Instead, the MySQLi or PDO_MySQLextension should be used. See also MySQL: choosing an API guide and related FAQ for more information.
Re: Random Sentences - Question
ok thx!