Insert Spaces Between Capital Letters in a String

Works well with formatting output of form field keys.

preg_replace(‘/(\w+)([A-Z])/U’, ‘\\1 \\2′, $string);

Leave a Reply