When working on a Laravel project, I needed a quick way to seed in some random (but still coherent) sentences.
The ultimate for PHP/Laravel projects is fzaninotto’s Faker, which can generate everything, from addresses to credit cards.
If you’re in need of something quick or less elaborate, then consider using linux’s fortune
.
Grab a short sentence/paragraph:
fortune -s
Grab a longer paragraph:
fortune -l
Here’s the man page for fortune.
If you want to process these manually, the text sources can be found in: /usr/share/games/fortunes
.
And if you just need a random word, check the /usr/share/dict
dir for a bunch of word files.
Random word (Bash script) (source):
WORDLINE=$((($RANDOM * $RANDOM) % $(wc -w /usr/share/dict/words | awk '{print $1}')))"p" && sed -n $WORDLINE /usr/share/dict/words
Random word (PHP script) (source):
<?php $f_contents = file("/usr/share/dict/words"); $line = $f_contents[rand(0, count($f_contents) - 1)];