I am interested whether the following php script can be written in Javascript (or HTML5)? Basically that is just a simple file reading a .txt and displaying a random line from it:
<?php
$text = file_get_contents('flatFileDB.txt');
$textArray = explode("\n", $text);
$randArrayIndexNum = array_rand($textArray);
$randPhrase = $textArray[$randArrayIndexNum];
?>
<html>
<body>
<h2><?php echo $randPhrase; ?></h2>
</body>
</html>
Example of 'flatFileDB.txt':
Line 1
Line 2
Line 3
Line 4
Line 5
...
...
etc
The example is taken from here: http://www.developphp.com/view.php?tid=1213, and I would like to do the same, but without server-side php. Is it even possible?