gpt4 book ai didi

php - 读取大文本文件并将所选行复制到另一个文件

转载 作者:行者123 更新时间:2023-12-04 02:56:05 27 4
gpt4 key购买 nike

我需要从 here 创建一个数据库表:

因此,我使用 curl 命令将同一文件复制到服务器文件夹。我需要从上述文本文件中检索 00-00-00 (hex) XEROX CORPORATION、00-00-01 (hex) XEROX CORPORATION 等。我只需要将十六进制值和组织的第一行复制到另一个文本文件。

我怎样才能用 PHP 做到这一点?

最佳答案

  <?php
// open the input and the output
$fp = fopen("http://standards.ieee.org/develop/regauth/oui/oui.txt","r");
$out = fopen("somefile.txt","w");

while($rec = fgets($fp)){
// check to see if the line contains '(hex)'
if (strpos($rec, '(hex)') !== false){
// if so write it out
fputs($out, $rec."\n");
}
}
fclose($fp);
fclose($out);

关于php - 读取大文本文件并将所选行复制到另一个文件,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/16684359/

27 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com