Regular Expressions 101

Make PHP var_dump() output more compact

Open Workspace
  • PCRE (Legacy)
  • Substitution
1

Regular Expression

`
(?|(\[[\"]?.+?[\"]?\])(=>)\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