---
title: "Slumpvalt citat?"
type: "forum-thread"
url: "https://www.webforum.nu/amne/php/14579-slumpvalt-citat"
topic: "PHP"
topic_url: "https://www.webforum.nu/amne/php"
author: "mike"
published: "2000-06-19T08:01:00.000Z"
updated: "2000-06-19T14:03:00.000Z"
replies: 3
views: 420
page: 1
pages: 1
language: "sv-SE"
site: "webForum — webforum.nu"
rights: "Upphovsrätten till varje inlägg tillhör dess författare."
attribution: "Citera som: webForum, https://www.webforum.nu/amne/php/14579-slumpvalt-citat"
---

# Slumpvalt citat?

## #1 — mike, 2000-06-19T08:01Z

Hur gör man ett script som slumpar ett citat på ens sida? Tack på förhand.

Permalänk: https://www.webforum.nu/p/14579

## #2 — Robban, 2000-06-19T11:00Z

Ett exempel:

```
<?php
$quotes = array(
  'Bättre en öl i handen än ett hål i tanden.',
  'Somliga tuvor stjälper bara små lass.',
  'Kul, sade han som fick tummen avhuggen.'
 );

srand((double)microtime()*1000000);

echo "<h1>Dagens citat</h1>";
echo "<p>".$quotes[rand(0,sizeof($quotes)-1)]."</p>";
?>
```

Permalänk: https://www.webforum.nu/p/311156

## #3 — Ryzzen, 2000-06-19T13:53Z

Ett exempel till.

Ett banner slump system

```
// Define
	$lnk = array(); 
	$img = array(); 
  
	// Setup
	$errormsg =  '<font size="2">Ett fel har uppståt</font>'; 
	
	/********************** Build arrays ***************************/
	// Build link array.
	$lnk[count($lnk)] =  'This is link 1 '; 
	$lnk[count($lnk)] =  'This is link 2 '; 
	$lnk[count($lnk)] =  'This is link 3 '; 

	// Build image array.
	$img[count($img)] =  'This is image 1'; 
	$img[count($img)] =  'This is image 2'; 
	$img[count($img)] =  'This is image 3'; 
  
	$count = count($lnk); 
	$i = date(s); 
	$i = $i%$count; 
  

	if($lnk[$i] != "" && $img[$i] != "")
	{ 
		echo("<A HREF='$lnk[$i]'><IMG SRC='$img[$i]' BORDER=0></A>"); 
	}
	else
	{ 
		echo($errormsg); 
	}
```

Permalänk: https://www.webforum.nu/p/311157

## #4 — mike, 2000-06-19T14:03Z

Man tackar och bugar! :)

Permalänk: https://www.webforum.nu/p/311158

---

Tråden på webben: https://www.webforum.nu/amne/php/14579-slumpvalt-citat
