[set some string to ] = preg_replace('[delimiter]pattern[delimiter][modifiers]', '[replace with]', [source string]);
The pattern:
/ = delimiter. Regexps require delimiters, they can be any character (for some reason a lot of PHP coders like to use #)
[] = character class. It means "match on anything inside these brackets." So [abc] would match on anything that contains a, b, or c. [0-9] and [\d] are synonymous, and match on any digit. The interesting thing about 0-9 is the dash, it defines a range. So [0-5] would only match on zero through five, [a-e] would only match on a, b, c, d, or e. Inversely, when ^ is used in a character class, it means anything NOT these characters. So
if (preg_match('/[^\d]+/',$somestring)) {
die ("$somestring contains one or more non-digits.");
}
Which brings us to ...
+ = one or more of the preceding pattern.
s = modifer, it modifies how the match is done, in particular, s insures the match includes newlines which is what you want here. Another common one is i, to match case insensitivity (which you don't need.) As an afternote, m (multiline) may also be useful here (added below.)
preg modifiers [php.net] So all together,
'/[\r\n]+/sm'
match on one or more newlines, whether they are defined by \r or \n or both, and don't ignore newlines in the match.