Skip to content

Instantly share code, notes, and snippets.

@WyriHaximus
Created April 24, 2014 13:38
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save WyriHaximus/11254879 to your computer and use it in GitHub Desktop.
Save WyriHaximus/11254879 to your computer and use it in GitHub Desktop.
$buffer = '';
$conn->on('data', function($data, $conn) use (&$buffer) {
$buffer .= $data;
if (strpos($buffer, PHP_EOL) !== false) {
$lines = explode(PHP_EOL, $buffer);
$buffer = array_pop($lines);
foreach ($lines as $line) {
// do something with $line
}
}
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment