Answer the question
In order to leave comments, you need to log in
Why PHP script does not remove all duplicate lines?
There is a script (running with cron):
<?php
$file= file ('sbor_proxy_s_dybliami.txt'); // файл на входе
sort ($file); // сортируем по алфавиту
$file = array_unique($file); // убираем повторы
foreach($file as $val){
$end .= $val ;
}
$out=fopen('gotovo_vse_sellery_bezdybley.txt','w'); // файл на выходе
fwrite($out,$end);
fclose($out);
Answer the question
In order to leave comments, you need to log in
I think this will solve the problem
sort ($file); // сортируем по алфавиту
$file = array_map('trim', $file); // <---------------
$file = array_unique($file); // убираем повторы
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question