03-02-2009, 01:11 AM
|
#2 (permalink)
|
|
Moderateur
Join Date: Apr 2007
Posts: 1,393
Thanks: 5
|
If you're after just a simple search, you could use fgets to grab the line and strpos to search it.
PHP Code:
// line: {"one":8405219,"two":4552659,"three":6640965}
$search = '"three":6640965';
$fp = fopen('misc.txt', 'r');
$result = 'No result';
while( ! feof($fp))
{
$line = fgets($fp, 70);
if (strpos($line, $search) !== FALSE)
{
$result = trim($line);
break;
}
}
fclose($fp);
echo $result;
For me, searching through a 46MB file with lines like yours took under two seconds to not find a match (worst case scenario).
|
|
|
|