Jump to content

[SOLVED] Reading a Random Line From a Text File


Recommended Posts

Hi :)

 

I'm new to PHP and so am unfamiliar about all the pros/cons of the many different methods of reading files.

 

I'm looking for a function that will allow me to quickly read a single line at random from a very large text file.

 

The text file will just be a very long list of words, with each word on a new line, I want to be able to pick one of these words at random.  The text file will also be local on my server and not a url.

 

Anyone able to help with the best solution?

 

Cheers

 

Gaz

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.