السلام عليكم
اخواني الكود يقوم بفحص ملف txt من الاشياء المتكررو و عرض المتكرر على المتصفح
و يعمل 100%
بحيث الكود يرفع الملف txt في نفس المجلد و يقوم بفحص الملف
اريد التعديل على الكود لكي يقوم بفحص الملف من قاعدة البيانات
الكود
<?php
ini_set('memory_limit', 32 * 1024 * 1024);
ini_set("max_execution_time", "200000");
$path=$_SERVER[DOCUMENT_ROOT]."/test/";
if( isset($_POST['upload']) )
{
$tmp_file = $_FILES['myfile']['tmp_name'];
if( !is_uploaded_file($tmp_file) )
{
exit("File not exist");
}
$name_file = $_FILES['myfile']['name'];
if( !move_uploaded_file($tmp_file, $path.$name_file) )
{
exit("Problem to upload this file");
}
if(file_exists($path.$name_file)) fileread($path.$name_file);
}
function fileread($file)
{
$tarray=array();
$f = fopen($file, "r");
while ( $line = fgets($f, 1000) ) {
$tarray[]= $line;
}
//
//
$tdouble=array();
for($i=0;$i<count($tarray)-1;$i++)
{
for($j=$i+1;$j<count($tarray);$j++)
{
if(trim($tarray[$i])==trim($tarray[$j])) {$tdouble[] =$tarray[$i];}//$tdouble[] =$tarray[$i];
}
}
echo "RESULT<br>";
foreach(array_unique($tdouble) as $value)
{
echo $value."<br>";
}
/*
echo "BEFORE<br>";
foreach($tarray as $value){
echo $value."<br>";
}
echo "AFTER<br>";
$newarray=array_unique ($tarray);
foreach($newarray as $value){
echo $value."<br>";
}
*/
}
//
?>
<form method=post action="./test.php" enctype="multipart/form-data">
<input type="file" name="myfile" style="width:500px;">
<input type="submit" name="upload" value="upload file">
</form>
</div>