On 1/1/2011 4:46 AM, Lester Caine wrote:
JohnDoeSMITH' or 'John Doe SMITH'

Try this. not tested.

First, which adds spaces as needed. e.g. JohnDoeSMITH > 'John Doe SMITH'

$newName=preg_replace("%(?<=[a-z])([A-Z])", " $1", $name);//Cap following low
case, add space before it

Next, alphas following a cap, lower case them

function lowCase($matches){return strtolower($matches[1]);}

$newName= preg_replace_callback("%(?<=[A-Z])([A-Z])%", "lowCase', $newName);

Sorry don't have time today to test; but, this should get you started.

PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php

Reply via email to