3v4l.org

run code in 300+ PHP versions simultaneously
<?php class SearchStream { public static function findLines( $keyword, $file ) { $stream = stream_get_contents( $file ); $lines = explode( "n", $stream ); $foundLines = []; foreach( $lines as $line ) { if( strpos( $line, $keyword ) ) { array_push( $foundLines, rtrim($line) ); } } return $foundLines; } } $stream = fopen( 'php://memory', 'r+' ); fputs( $stream, "Hello, there!nHow are you today?nYes, you over there." ); rewind( $stream ); print_r( SearchStream::findLines( 'there', $stream ) );

preferences:
47.48 ms | 402 KiB | 5 Q