jasonc Posted August 3, 2008 Share Posted August 3, 2008 $string = "JoeBloggs"; or $string = "MarySmith"; how do i get the first part of the string before the second upper case letter? Mary or Joe thanks PHP5 server Quote Link to comment Share on other sites More sharing options...
JasonLewis Posted August 3, 2008 Share Posted August 3, 2008 Well, I suppose you could do it like this: $string = "JoeBloggs"; $split = preg_match_all("#[A-Z]{1}[a-z]+#",$string,$match); print_r($match); Quote Link to comment Share on other sites More sharing options...
PHPTOM Posted August 3, 2008 Share Posted August 3, 2008 <?PHP $string = "JoeBloggs"; $spliter = split(",",substr(preg_replace("/([A-Z])/",',\\1',$string),1)); $forename = $spliter[0]; $surname = $spliter[1]; ?> This can also be used if $string = "JoeBloggsWithMoreCaps"; Quote Link to comment Share on other sites More sharing options...
jasonc Posted August 3, 2008 Author Share Posted August 3, 2008 thanks for that, i really appreciate it. Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.