Jump to content

flat file help please thank you.


redarrow

Recommended Posts

Not sure why its not displaying code for me, but one more try...

--- note this proceedure IS case sensitive
[code]<?PHP

$file_name = "some_data.dat";// set data file name


$needle = "John";// set search variable


$fp = f open($file_name, 'r'); // open the data file
// remove the space between f and open - for some reason the board will NOT let me post the code properly


$haystack = f read($fp, filesize($file_name));// read the entire contents of the file into a string
// remove the space between f and read - for some reason the board will NOT let me post the code properly

$ntimes = substr_count($haystack, $needle);// count times $needle is in $haystack

if ($ntimes > 3) {
  // do something
}
?>[/code]


Lite...

Archived

This topic is now archived and is closed to further replies.

×
×
  • 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.