All pastes #880487 Raw Edit

Stuff

public text v1 · immutable
#880487 ·published 2008-01-29 20:23 UTC
rendered paste body
<?php
$starttime = explode(' ', microtime());
$starttime = $starttime[1] + $starttime[0];

function getRandArray($array, $skip = ""){
  $num = rand(0, count($array)-1);
  if($skip != ""){
    if($skip == $array[$num]){
      getRandArray($array, $skip);
    } else {
      return $num;
    }
  } else {
    return $num;
  }
}

// function replaceWords($array, $type, $structure){
//   $wordies = array();
//   $sar = explode(" ", $structure);
//   for($i=0;$i<count($sar);$i++){
//     if($sar[$i] == $type){
//       array_push($wordies, $array[getRandArray($array)]);
//     } else {
//       array_push($wordies, $sar[$i]);
//     }
//   }
//   $word = "";
//   for($a=0;$a<count($wordies);$a++){
//     if($a == count($wordies)-1){ $word .= $wordies[$a]; } else { $word .= $wordies[$a]." "; }
//   }
//   return $word;
// }

$numwords = rand(1,300);

$subst = array("procrastination", "entropy", "fantasy", "business", "montage", "sapphire", "incarnation",
               "sound", "python", "liberation", "literacy", "scope", "zombies", "armada", "motion", "eyeball",
               "compound", "philosophy", "strategy", "lounge", "steampunk", "decepticon", "transformer",
               "pulse", "assembly", "sequence", "democracy", "essence", "snow", "phenomena", "future", "genius",
               "robot", "revolution", "assistant", "opposition", "awareness", "assessment", "dusk");
$adj = array("über", "diurnal", "dual", "questionable", "uncanny", "black", "fatal", "spasmodic", "involuntary",
             "tangible", "credible", "fungible", "mallow", "perfect", "unbeknownst", "independent", "effective",
             "mindless", "simple", "funktastic", "fantastic", "sharp", "invincible", "invisible", "compressive",
             "impulsive", "implodive", "typical", "utilitarian", "instant", "compliant", "cinematic", "complex",
             "organic", "nostalgic", "ambient", "distorted", "synthetic", "triumphant", "aspiring", "acoustic",
             "exceptional", "international", "eccentric", "magnificent", "casual", "citable", "geothermal",
             "mistakable", "");
$pre = array("re", "pre", "di", "bi", "tri", "un", "quasi", "non-");

if($numwords <= 80){$structure = " s ";}
if($numwords > 80 and $numwords <= 220){
  $st = rand(1,2);
  if($st = 1){$structure = " s s ";}
  if($st = 2){$structure = " a s ";}
}
if($numwords > 220){
  $st = rand(1,3);
  if($st = 1){$structure = " a s s ";}
  if($st = 2){$structure = " a a s ";}
  if($st = 3){$structure = " s of s ";}
}

function gwa($type, $array, $source){
  global $pre;
  $r = rand(0,100);
  if($source != " s of s "){
    if($r < 80){
      $w = str_replace(" ".$type." ", " ".$array[getRandArray($array)]." ", $source);
    } else {
      $pr = rand(0,count($pre)-1);
      $w = str_replace(" ".$type." ", " ".$pre[$pr].$array[getRandArray($array)]." ", $source);
    }
  } else {
    if($r < 80){
      $w = $array[getRandArray($array)]." of s ";
    } else {
      $pr = rand(0,count($pre)-1);
      $w = $pre[$pr].$array[getRandArray($array)]." of s ";
    }
  }
  return $w;
}
$name = str_replace(" a ", " ".$adj[getRandArray($adj)]." ", $structure);
$name = str_replace(" a ", " ".$adj[getRandArray($adj)]." ", $name);
$name = gwa("s", $subst, $name);
$name = gwa("s", $subst, $name);

$name = str_replace(" pree", " pre-e", $name);
$name = str_replace(" ree", " pre-e", $name);
$name = str_replace(" dii", " di-i", $name);
$name = str_replace(" bii", " bi-i", $name);
$name = str_replace(" trii", " tri-i", $name);
$name = str_replace(" didi", " di", $name);

// $name = str_replace(" a ", " ".$adj[getRandArray($adj)]." ", $structure);
// $name = str_replace(" a ", " ".$adj[getRandArray($adj)]." ", $name);
// $name = str_replace(" s ", " ".$subst[getRandArray($subst)]." ", $name);
// $name = str_replace(" s ", " ".$subst[getRandArray($subst)]." ", $name);

// $name = replaceWords($adj, "a", $structure);
// $name = replaceWords($subst, "s", $name);


$hits = file_get_contents("hits.txt");

settype($hits, "int");
$handle = fopen("hits.txt", "w+");
fwrite($handle, $hits+1);
fclose($handle);

$lastc = substr($hits+1, -1);
switch($lastc){
  case '1':
    $th = 'st';
    break;
  case '2':
    $th = 'nd';
    break;
  case '3':
    $th = 'rd';
    break;
  default:
    $th = 'th';
    break;
}
?>