quote generator Tool – Free Random Quote Generator 100% Working

quote generator : In this post, you will learn a very simple source code to generate random quote in PHP that generates a random quote every time the web page loads : quote generator.

here you can make a free online tool that will generate random motivational quotes including best uplifting quotes, inspirational quotes, and interesting quotes.

This generator randomly display from your all the text file collection of favorite random quotes.

quote generator

Some latest website show random list of the quotes to its visitors on different web pages. This is generally used on websites like press releases, speech or news story, as a good random quote generator can help us to enhance the credibility.

It needs to store the data contents of quotes either in an array or in a text file like as a web-development-quotes.txt. Here, i have mentioned both ways to display random quote –

Read Also:  Google Invisible ReCAPTCHA Automatically
quote generator
quote generator

Quote Generator 1

For Example, I have a text file ‘web-development-quotes.txt’ that contain contexts of quotes.

O what a tangled web we weave when first we practise to deceive
One cannot separate the spider webs form from the way in which it originated
What we did not imagine was a Web of people but a Web of documents
On the Web we all become small-town visitors lost in the big city
The web of life love suffering and death unites all beings
In the information age man and spider both live in a web 

Random Quote Generator 2

The given PHP source code loads the contents of the file and arbitrarily displays a line from it. You can utilize this to display an arbitrary statement on a web page each time it loads – quotes generator.

Read Also:  Saving image from PHP URL - PHP Download Image from Url

<?php
$file= "web-development-quotes.txt";
$slogens = file($file);
srand((double)microtime()*1000000);
$randomquote = rand(0, count($slogens)-1);
echo $slogens[$randomquote];
?>

Here is a sample results –

One cannot separate the spider webs form from the way in which it originated

Random Quote Generator 2


In the given best example, i have stored the random quote in an array and used the rand() method to randomly display only one at a time.

<?php  
  $slogens[] = 'O, what a tangled web we weave when first we practise to deceive!';
  $slogens[] = 'One cannot separate the spider webs form from the way in which it originated';
  $slogens[] = 'On the Web we all become small-town visitors lost in the big city ';
  $slogens[] = 'What we did not imagine was a Web of people, but a Web of documents ';
  $slogens[] = 'The web of life, love, suffering and death unites all beings ';
  $slogens[] = 'In the information age, man and spider both live in a web. ';

  srand ((double) microtime() * 1000000);
  $random_number = rand(0,count($slogens)-1);

  echo ($slogens[$random_number]);
?>