<?php
// specify which directory to read
$dir = "./folder";
// open directory for read operation
$handle = opendir( $dir );
// obivously, you shouldn't include '.', and '..'
// you can add more if you wish, for example
// if you are on windows, you should exclude Thumb.db also
$not_included = array( ".", ".." );
// array to append files into
$my_files = array();
while( $file = readdir( $handle ) )
{
// check that $file is not a directory
// and that it has not been specified in $not_included array
if( !is_dir( $file ) && !in_array( $file, $not_included ) )
{
array_push( $my_files, $file );
} // ends if
} // ends while loop
// close directory, we are done reading it
closedir( $handle );
// calculate the number of files in the array
$array_size = count( $my_files );
// get a random number between 0 and the size of the array - 1
$which_file = rand( 0, $array_size - 1 );
// now include the file selected at random
include $dir . "/" . $my_files[ $which_file ];
?>
E sad...
Moze li molim vas neko pomoci da ovo
include $dir . "/" . $my_files[ $which_file ];
promenim u varijablu kao sto bi bila na primer $newrandomtext da bih je mogao koristiti vise puta unutar sablona?
Pokusao sam nesto ovako
$newrandomtext = file_get_content("$dir . "/" . $my_files[ $which_file ]");
echo "$newrandomtext";
ali ne radi

Hvala unapred svima na pomoci