There is a file prepare_image.out which reflects the information of the form:
copy "..\какой-то путь\1.txt" to "..\путь\сюда" 1 File(s) copied copy "..\какой-то путь\2.txt" to "..\путь\сюда" 0 File(s) copied There are a lot of such lines and all reflect information about which file is being copied and information, whether the file was copied or not.
I implemented the search as follows:
$temp = fopen("prepare_image.err", "a+"); $log = 'prepare_image.out'; $arr_log = file($log); $date = count($arr_log); $needle = '0 File(s) copied'; for ($i = 0; $i <= $date; $i++) { $read = $arr[$date - $i]; $pos = strripos($read, $needle); if ($pos === false) { echo "Ошибок, при копирование не обнаружено."; break; } else { echo "Warning! Обнаружены ошибки при копирование."; $string = substr($read, 0); fwrite($temp, $string ."\n"); } } Search is organized from the end of the file.
And here only the lines 0 File (s) copied fall into prepare_image.err, and you need to output the line OVER found 0 File (s) copied
That is, output $date - ($i+1) to another file
How can this be realized?