FULL STACK   ·   UI   ·   UX   ·   GRAPHICS   ·   DEVELOPER   ·   INSTRUCTOR

Adam Khoury

Donate funds to show love and support

Click the button below to donate funds securely online. You can use your PayPal account or a credit card.

Your donations help free up my time to produce more content and assist in covering server costs. It's also a great way to say thanks for the content!

Application Configuration

Adam will be adding options here soon.

Random Array Items From Flat Text File Database Tutorial

Published :
Author :
Adam Khoury
In this exercise we put several built in PHP functions to use in order to turn an idea into an application. We take the described logic and translate it into script by accessing knowledge we have of PHP's built in functions and applying them. Some people have to use text files in place of MySQL for data management so this lesson is another one that deals with text file data handling for dynamic purposes on a website. <?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> flatFileDB.txt Hello and Welcome! Hi how are you today? Welcome Pilgrims! Hey There Weenis! Howdy Partner! Hola Amigos! Hallo Vrienden! Bonjour Les Amis! Cairde Dia duit! Cras Venenatis!