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: How to pick ~15 lines of text from a textfile and put them on my site? (https://gfy.com/showthread.php?t=590492)

More Booze 03-24-2006 03:26 PM

PHP: How to pick ~15 lines of text from a textfile and put them on my site?
 
I know we got some good PHP programmers around here. Anyone want to help me with this?

I got a textfile with about ~500 lines of text. I want to pick like 15 random lines and show them on my page.

Anyone know how I can do this?

Evil Doer 03-24-2006 03:44 PM

I can do that for you.

ICQ to the left.. :)

pstation 03-24-2006 03:50 PM

pretty simple...

Code:

<?php
$a = file("somefile.txt");
for($b=0;$b<15;$b++)
  echo $a[array_rand($a)];
?>

just off the top of my head, there's always a chance that you might get a duplicate line but it should give you a good start..

More Booze 03-24-2006 04:12 PM

Quote:

Originally Posted by pstation
pretty simple...

Code:

<?php
$a = file("somefile.txt");
for($b=0;$b<15;$b++)
  echo $a[array_rand($a)];
?>

just off the top of my head, there's always a chance that you might get a duplicate line but it should give you a good start..

Very nice, thank you very much! Works great. :thumbsup :thumbsup


All times are GMT -7. The time now is 06:52 PM.

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