Regular Expressions 101

Community Patterns

Make PHP var_dump() output more compact

1

Regular Expression
PCRE (PHP <7.3)

`
(?|(\[[\"]?.+?[\"]?\])(=>)\R\s*|(?<=\(0\) )(\{)\R\s*(\}))
`
g

Description

The PHP function var_dump() provides debugging output, but has more line-breaks than is needed for readability. This regex strips out the (in my eyes) unnecessary line-breaks. Good in a self written debugging method in combination with ob_start()and ob_get_contents().

Submitted by Doqnach - 7 years ago