Title: Random Text/HTML Using PHP
Last modified: August 19, 2016

---

# Random Text/HTML Using PHP

 *  Resolved [Connor Crosby](https://wordpress.org/support/users/ccmovies/)
 * (@ccmovies)
 * [15 years, 3 months ago](https://wordpress.org/support/topic/php-refresh-random/)
 * I am making a theme and part of it shows a random quote. How can I use PHP to
   choose randomly a quote. Then, if they refresh the page, it shows a different
   one. I am not very good with PHP but I think it involves random or if/else. Thanks!

Viewing 8 replies - 1 through 8 (of 8 total)

 *  Thread Starter [Connor Crosby](https://wordpress.org/support/users/ccmovies/)
 * (@ccmovies)
 * [15 years, 3 months ago](https://wordpress.org/support/topic/php-refresh-random/#post-1827176)
 * /* bump */
 *  [Michael](https://wordpress.org/support/users/alchymyth/)
 * (@alchymyth)
 * [15 years, 3 months ago](https://wordpress.org/support/topic/php-refresh-random/#post-1827177)
 * > I am not very good with PHP but I think it involves random
 * have you ever thought of searching the web for ‘random php’ which would have 
   pointed you to a few possible sites with php tutorials?
 * anyway, one possibility out of many:
 * put your quotes into an array, and select a random counter; something along those
   lines:
 *     ```
       <?php
       $quotes = array(
       'Too good to be true',
       'The greatest prayer is patience  - The Buddha',
       'Another Quote',
       'If the WHY is big enough, the HOW looks after itself.'
       );
       $rand = rand( 0, count($quotes)-1 );
       echo $quotes[$rand];
       ?>
       ```
   
 * [http://php.net/manual/en/function.rand.php](http://php.net/manual/en/function.rand.php)
 *  [theApe](https://wordpress.org/support/users/theape/)
 * (@theape)
 * [15 years, 3 months ago](https://wordpress.org/support/topic/php-refresh-random/#post-1827178)
 * Where are you pulling the quotes from? Is it a set of posts, a separate file 
   or are you listing them in the code and you only want a random one to appear?
 *  Thread Starter [Connor Crosby](https://wordpress.org/support/users/ccmovies/)
 * (@ccmovies)
 * [15 years, 3 months ago](https://wordpress.org/support/topic/php-refresh-random/#post-1827179)
 * I tried searching for it but I didn’t find anything. This will work if I have
   the text in `blockquote` right? Thank you!
 *  Thread Starter [Connor Crosby](https://wordpress.org/support/users/ccmovies/)
 * (@ccmovies)
 * [15 years, 3 months ago](https://wordpress.org/support/topic/php-refresh-random/#post-1827180)
 * I am listing them. I will not be using any WordPress code for that part. I would
   like one to be randomly chosen.
 *  Thread Starter [Connor Crosby](https://wordpress.org/support/users/ccmovies/)
 * (@ccmovies)
 * [15 years, 3 months ago](https://wordpress.org/support/topic/php-refresh-random/#post-1827181)
 * That seemed to do the trick. Thank you!
 *  [theApe](https://wordpress.org/support/users/theape/)
 * (@theape)
 * [15 years, 3 months ago](https://wordpress.org/support/topic/php-refresh-random/#post-1827183)
 *  Thread Starter [Connor Crosby](https://wordpress.org/support/users/ccmovies/)
 * (@ccmovies)
 * [15 years, 3 months ago](https://wordpress.org/support/topic/php-refresh-random/#post-1827185)
 * Oops, I meant quote, not blockquote.

Viewing 8 replies - 1 through 8 (of 8 total)

The topic ‘Random Text/HTML Using PHP’ is closed to new replies.

## Tags

 * [else](https://wordpress.org/support/topic-tag/else/)
 * [if](https://wordpress.org/support/topic-tag/if/)
 * [ifelse](https://wordpress.org/support/topic-tag/ifelse/)
 * [php](https://wordpress.org/support/topic-tag/php/)
 * [text](https://wordpress.org/support/topic-tag/text/)

 * 8 replies
 * 3 participants
 * Last reply from: [Connor Crosby](https://wordpress.org/support/users/ccmovies/)
 * Last activity: [15 years, 3 months ago](https://wordpress.org/support/topic/php-refresh-random/#post-1827185)
 * Status: resolved

## Topics

### Topics with no replies

### Non-support topics

### Resolved topics

### Unresolved topics

### All topics
