Sunday, May 19 in 2024
Modul: Random Text
Author: Ralf Hertsch
Nick: Ralf (Berlin)
Version: 0.1.0
State: Alpha
License: GPL
Platform: 2.7
Last info: 2008-10-14
594 votes
1 2 3 4 5
Download: here
Forum: here
Description: A code snippet to show random text on pages.
See also:


Place this code in your template or on a code page:

// file with random text
$random_txt_file = 'yourfile.txt';

// intitialize random gerator

if (file_exists($random_txt_file)) {
  // read random text to array
  $array_txt = preg_split("/ NEXT /", join('', file($random_txt_file)));
  // search and display text
  echo $array_txt[rand(0, sizeof($array_txt) -1)]; }
else {
  echo "file for random text not found!"; }


create a "yourfile.txt" file:

<p>Any text or code no 1</p>
<p>Any text or code no 2</p>
<p>Any text or code no 3</p>
<p>Any text or code no 4</p>
<p>Any text or code no 5</p>
<p>Any text or code no 6</p>



and see the result:

Any text or code no 2