Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
目前我正在使用 PHP 通过 Telnet 连接制作数据解析器。我遇到了问题:我需要将指针放在流中指向某个位置(而不是数据末尾),但是使用流不可能使用 fseek() 函数。请告诉我,我该如何解决这个问题?
此功能应将您的流光标移动到所需的位置:
function moveStreamCursorTo(&$fp, $offset) { for ($i = 0; $i < $offset; $i++) fgetc($fp); } // Use like this: $curPos = 459; $desiredPos = 1345; moveStreamCursorTo($yourStream, $desiredPos - $curPos);
请对此进行测试并报告您的结果。