# Very Random Page

**URL:** <https://forum.kirupa.com/t/very-random-page/221427>\
**Category:** open source\
**Created:** [April 4, 2007, 8:39am UTC](https://forum.kirupa.com/t/very-random-page/221427 "2007-04-04T08:39:49Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![puppy](https://avatars.discourse-cdn.com/v4/letter/p/e56c9b/32.png) [@puppy](https://forum.kirupa.com/u/puppy)\
**Post date:** [April 4, 2007, 8:39am UTC](https://forum.kirupa.com/t/very-random-page/221427/1 "2007-04-04T08:39:49Z")

</div>

I need your help with [this](http://myjobsuck.com/exp/random.php), I mean ideas for content easy to generate. So far, things on my list are videos, equations and something I can’t mention here.

Since this is source section, here you go:

```php
  $n = -1;
  $r = (1.0 * mt_rand ()) / mt_getrandmax (); // 0..1
  if (isset ($_GET['n'])) {
    preg_match ("/^\d\.\d+$/", $_GET['n'], $matches);
    if (count ($matches) > 0) {
      $n = 0 + $matches[0];
      if (($n >= 0) && ($n <= 1)) {
        // override random value
        $r = $n;
      }
    }
  }
  else {
    // $_GET['n'] is not set, send no-cache headers
    header("Expires: Mon, 26 Nov 1962 00:00:00 GMT");
    header("Last-Modified: " . gmdate("D,d M Y H:i:s") . " GMT");
    header("Cache-Control: no-cache, must-revalidate");
    header("Pragma: no-cache");
  }
  // array helper
  function pick ($arr) {
    global $r;
    return $arr [round ($r * (count ($arr) - 1))];
  }

```

The rest is fairly obvious.
