GoFuckYourself.com - Adult Webmaster Forum

GoFuckYourself.com - Adult Webmaster Forum (https://gfy.com/index.php)
-   Fucking Around & Business Discussion (https://gfy.com/forumdisplay.php?f=26)
-   -   PHP Script help (https://gfy.com/showthread.php?t=173114)

raster 09-10-2003 11:27 PM

PHP Script help
 
I've got a cgi script that allows me to add the output of a php script to an html page using the following line of code.

#insert : http://www.url.com/sript.php#

What I'm wondering is if someone could write me a couple of lines of code for script.php that would randomly select one line of information from a text file called text.txt.

This way, if I had the following line in my html file, the place where #insert : http://www.url.com/sript.php# is located, would be replaced by a random line of text from text.txt.

<a href="http://www.yahoo.com">#insert : http://www.url.com/sript.php#</a>

Thanks

JSA Matt 09-10-2003 11:40 PM

keep it simple : )

PHP Code:

<?php
    $file        
"random.txt";
    
$file_Content    file($file);

    if (
count($file_Content) > 0)    {
        
$line $file_Content[rand(0,count($file_Content)-1)];
    
    echo 
$line;
    }
?>


myneid 09-10-2003 11:41 PM

i see now you beat me to it

raster 09-11-2003 12:01 AM

Quote:

Originally posted by JSA Matt
keep it simple : )

PHP Code:

<?php
    $file        
"random.txt";
    
$file_Content    file($file);

    if (
count($file_Content) > 0)    {
        
$line $file_Content[rand(0,count($file_Content)-1)];
    
    echo 
$line;
    }
?>


Thanks very much, works great.


All times are GMT -7. The time now is 11:37 AM.

Powered by vBulletin® Version 3.8.8
Copyright ©2000 - 2025, vBulletin Solutions, Inc.
©2000-, AI Media Network Inc123