Here's how to do it with a regular expression (substitution) which will replace the first 3 matches with empty string and leave the rest of the string untouched: preg_replace('/.*?\n/', '', $str, 3)