Code in Chaos

Handy snippets - really need to organize this stuff

Here is the snippette and data for a word or phrase random generator that reads an external text file, great for a massive list of items but requires access to your webservers filesystem.

trivia.php

<?php
$quote=file("quotes.txt");
$totalnumberofquotes=count($quote);
$rdm=rand(1,$totalnumberofquotes);
echo $quote[$rdm];
?>

quotes.txt
vision 
loiterer 
observatory
century 
Atlantis 
kilogram
neutron 
stowaway 


Launch random example




Inline random line genertor...

<script>
var things = [
'Afraid','Apparition','Bat','Bloodcurdling','Bloody','Bones','Broomstick','Cackle','Cadaver','Carved','Casket','Cauldron','Cemetery','Cobweb','Coffin','Corpse','Creepy','Decapitated','Decomposing','Eerie','Fangs','Frightening','Ghost','Ghoulish','Goblin','Gory','Grim Reaper','Gruesome','Haunted','Horrifying','Howling','Jack-O-Lantern','Lurking','Macabre','Magic','Mausoleum','Morbid','Mummy','Occult','Owl','Petrified','Phantom','Poltergeist','Scary','Scream','Shadow','Skeleton','Skull','Specter','Spell','Spider','Spirit','Superstition','Tomb','Trick or treat','Undead','Unearthly','Unnerving','Vampire','Warlock','Werewolf','Witch','Wizard','Zombie'];
var thing = things[Math.floor(Math.random()*things.length)];
</script>