View Full Version : Small script that include *.txt files to page randomly
Yahook
05-28-2005, 08:37 PM
<?php
$files = array( 'file1.txt', 'file2.txt' );
readfile( $files[rand(0, sizeof( $files ) - 1 ) ] );
?>
I think it will be usefull for somebody
ghood
06-09-2005, 11:20 PM
Thanks yahook, very useful snippet :wink:
You could execute random PHP scripts using this:
<?php
$files = array( 'file1.inc', 'file2.inc' );
@include( $files[rand(0, sizeof( $files ) - 1 ) ] );
?>
Just change readfile function to include :)
xariton
06-11-2005, 07:35 AM
This script makes redirect to random URL from file.
<?
$file=file("file.txt");
$rand=array_rand($file);
$url=trim($file[$rand]);
header("Location: $url");
?>
Hardcore-XTC
09-15-2005, 01:21 PM
very useful. iv been using Apaches RewriteRule but this method would be alot better.
thanks