---
title: "Spango"
type: "forum-thread"
url: "https://www.webforum.nu/amne/php/16533-spango"
topic: "PHP"
topic_url: "https://www.webforum.nu/amne/php"
author: "vicktor"
published: "2002-01-05T19:15:00.000Z"
updated: "2002-01-05T21:17:00.000Z"
replies: 1
views: 164
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/16533-spango"
---

# Spango

## #1 — vicktor, 2002-01-05T19:15Z

Hej jag undrar hur man kan göra för att slumpa fram mer än 3 texter på detta:

$texts = array(
array('text 1', 'text 2', 'text 3'),
array('text 4', 'text 5', 'text 6'),
array('text 7', 'text 8', 'text 9'),
array('text 10', 'text 11', 'text 12'),
array('text 13', 'text 14', 'text 15'),
array('text 16', 'text 17', 'text 18'),
array('text 19', 'text 20', 'text 21')
);
echo $texts\[date('w')\]\[mt_rand(0, 2)\];

Hitta detta på wf det är Spango som har skrivit den.

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

## #2 — Asterix, 2002-01-05T21:17Z

Ta bort din sista rad och ersätt den mot dessa:

```
$day = date('w');
$antal = count($texts[$day]) - 1;

if ($antal == 0) {
  echo $texts[$day][0];
} else {
  echo $texts[$day][mt_rand(0, $antal)];
}
```

Så kan du ange hur många texter du vill varje dag, men minst en.

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

---

Tråden på webben: https://www.webforum.nu/amne/php/16533-spango
