Answer the question
In order to leave comments, you need to log in
How to avoid duplicate entries in a large list?
Let's say we have this code:
<?php
function getlist($string){
if($string>0 && file_exists('./list.txt') && filesize('./list.txt')>=($string*2)){
$list=fopen('./list.txt', 'a+');
fseek($string*2-2);
return fgets($list, 1);
}
}
function putlist($data){
if($data){
$data=substr($data, 0, 1);
file_put_contents('./list.txt', $data."\n", FILE_APPEND);
}
}
$data=$_GET['data']; //$data=='d';
for($i=1; $d=getdata($i), $d; $i++){
if($d===$data){
$cancel=true;
break;
}
}
if(!$cancel)
putdata($data);
Answer the question
In order to leave comments, you need to log in
Are you for a one-time use (to clean the base) or for permanent use?
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question