Friday, January 22, 2010

Split string of combined camel case words

<?php
$string = 'ThisIsATest';
$result = preg_replace('/(?<=[a-z])[A-Z]/', ' $0', $string);

echo $result;
//OUTPUTS: This Is A Test
?>

No comments:

Post a Comment