I just skimmed over your post and if I can quickly guess your question, it sounds like you have data randomly sitting in an array that you want to extract. I would check out this function:
http://us2.php.net/manual/en/function.preg-grep.php
Basically you can perform an expression on each element of the array, and it will return the array element that has that match.
Lemme know if that helped at all.
Have been able to produce a file containing all the filenames in a path, data such as
Because the report that produced the file was sorted to CRC, I'd like to simply open the file, read the contents, line by line, and where the CRC is the same as the previous line, then add details to an array. Then after completing to read the file/report, either display the array, or make code from it, and write to a bash file (like 'rm filename' commands).
Here is the php code so far
<?php$handle = @fopen("~/Documents/temp/Report.txt", "r");
if ($handle) {
while (!feof($handle)) {
$buffer = fgets($handle, 4096);
echo $buffer;
$pieces = explode(" ", $buffer);
print_r($pieces);
}
fclose($handle);
}
?>
The echo and print_r are just to see how the data looks to php. Now, the explode does this
The filename is always in element/key zero it seems, but the size and CRC are in different array keys, depends on the data.
How can I do the split (or similar) just to get the filename, size and CRC ? I also want to bypass the first 7 lines, and also bypass lines like this
Once I am able to get the filename, size and CRC, it can be simply stored in variables, and then compare the values from the next line read in the file.
Thanks,
J