$re = '/^frame=(?\'frame\'\s*[\d]+\n)fps=(?\'fps\'\s*.*?\n).+bitrate=(?\'bitrate\'\s*.*?)k.+out_time_ms=(?\'time\'\s*.*?)\n.+speed=(?\'speed\'\s*.*?)\n/ms';
$str = 'frame=160
fps=0.00
stream_0_0_q=-1.0
bitrate=1431.0kbits/s
total_size=957885
out_time_us=5355167
out_time_ms=5355167
out_time=00:00:05.355167
dup_frames=0
drop_frames=0
speed=27.3x
progress=end
';
preg_match_all($re, $str, $matches, PREG_SET_ORDER, 0);
// Print the entire match result
var_dump($matches);
Please keep in mind that these code samples are automatically generated and are not guaranteed to work. If you find any syntax errors, feel free to submit a bug report. For a full regex reference for PHP, please visit: http://php.net/manual/en/ref.pcre.php