Alright, I am trying to create a code to scan all text files in a directory, then each line in the text files have sections seperated by a "|". I need to insert each section in a line into an array, but i am totally stumpt. This is what i have:
<?php $path = './';$findThisString = '|';$dir = dir($path);// Get next file/dir name in directorywhile (false !== ($file = $dir->read())){ if ($file != '.' && $file != '..') { // Is this entry a file or directory? if (is_file($path . '/' . $file)) { // Its a file, yay! Lets get the file's contents $data = file_get_contents($path . '/' . $file); // Is the str in the data (case-insensitive search) if (stripos($data, $findThisString) !== false) { $file2 = fopen($file, "r"); while (!feof($file2)) { $results = explode("|",fgets($file2)); } fclose($file2); for($i = 0; $i < count($results); $i++) { echo $results[$i]; unset($results[$i]); } } } }}$dir->close();?>
Any ideas?