Php 比较两个上载的文件
我想比较两个上传的文件,并显示两个文件中相同的字符串通知百分比,但我不知道如何处理它。非常感谢您的帮助。下面是我的上传表格Php 比较两个上载的文件,php,file-upload,file-io,file-comparison,Php,File Upload,File Io,File Comparison,我想比较两个上传的文件,并显示两个文件中相同的字符串通知百分比,但我不知道如何处理它。非常感谢您的帮助。下面是我的上传表格 <p>Choose files to be compared<p> <hr /> <form action="" method="post" enctype="multipart/form-data" name="form1" id="form1">
<p>Choose files to be compared<p>
<hr />
<form action="" method="post" enctype="multipart/form-data" name="form1" id="form1">
<!--APC hidden field-->
<input type="hidden" name="APC_UPLOAD_PROGRESS" id="progress_key" value="<?php echo $up_id; ?>"/>
<!---->
<input name="file" type="file" id="file" size="30"/>
<!--Include the iframe-->
<br />
<iframe id="upload_frame" name="upload_frame" frameborder="0" border="0" src="" scrolling="no" scrollbar="no" > </iframe>
<br />
<!---->
<!--APC hidden field-->
<input type="hidden" name="APC_UPLOAD_PROGRESS" id="progress_key1" value="<?php echo $up_id; ?>"/>
<!---->
<input name="file1" type="file" id="file1" size="30"/>
<!--Include the iframe-->
<br />
<iframe id="upload_frame" name="upload_frame" frameborder="0" border="0" src="" scrolling="no" scrollbar="no" > </iframe>
<br />
<!---->
<input name="Submit" type="submit" id="uploadFilesButton" style="width:250px; height:35px; background-color: #003333; color: #ffffff; border-radius: 10px;" value="PlagCheck" />
</form>
选择要比较的文件
这篇文章()可能会有所帮助。所以你可以这样做:
file\u get\u contents
(将每个文件内容放入字符串中)
将字符串内容拆分为单词数组(explode(“,$str);
)
存储要获取百分比的文件的字数(例如File1)
删除File1数组中File2数组中的所有单词
foreach($file2array作为$word){if(在数组中($word,$file1array)){unset($file1array[$word])}
在此阶段获取File1数组的长度
使用步骤3和步骤5中的数字获取百分比
搜索“php差异”。