Hello! Currently I'm making data parser via Telnet connection using PHP. I've encountered problem: I need to put pointer in a stream to the certain place(not to the end of data), but using of fseek() function is impossible with streams. Tell me, please, how can I solve this problem?
+2
A:
This function should move your stream cursor to the desired place:
function moveStreamCursorTo(&$fp, $offset)
{
for ($i = 0; $i < $offset; $i++)
fgetc($fp);
}
// Use like this:
$curPos = 459;
$desiredPos = 1345;
moveStreamCursorTo($yourStream, $desiredPos - $curPos);
Please test this and report your results.
Franz
2009-12-01 12:48:31
Thank you for rapid reply.Your function works perfectly with telnet.But I've just found, that I can use stream_get_line() function for solution, because it allows to separate data by the specified symbol. So this function is more appropriate in this case. However, thank you very much for help.P.S. Sorry for my English, I'm not native speaker.
Alex
2009-12-01 14:07:33
That's fine. And so is your English ;)
Franz
2009-12-01 14:32:57