Jump to content

Recommended Posts

i'm working on a project for a gameing server. they have all kills stored in a txt file. my project is to sort by the highest kills and down the last hour. i've tried using file() but reading every line into an array every time takes way to long. is there another way to read this file faster?

 

Thanks In Advance

- Clown

Link to comment
https://forums.phpfreaks.com/topic/88043-reading-large-txt-files/
Share on other sites

$fp = fopen($file,"r");

$conetents = fread($fp,sile_size($file));

 

On my server that will read a 5mb file in seconds.

 

this is the same as using file_get_contents()

<?php
$conetents = file_get_contents($file);
?>

 

but if you have a memory problem (or performance) you should not load all this data into the memory.

 

 

link=topic=179218.msg798214#msg798214 date=1201446095]

well this file is on a remote server, and it contains everything from 100 to over 100,000 lines =) so fopen() is the one i should use?

 

i'm not sure...because in this case if you use http protocol, there is no benefits for the fopen().....

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.