dmccabe Posted July 6, 2011 Share Posted July 6, 2011 Ok I have this text: User Name (Real Name) I want to grab the text "User Name" and "Real Name" separately? How can I split them, I know it has something to do with Strpos and Substr, but I just cant get it right or anywhere close, this is where I get before getting all kinds of confused: $pos = strpos($author, "("); $name= substr($author, $pos, -1); Quote Link to comment Share on other sites More sharing options...
Zane Posted July 6, 2011 Share Posted July 6, 2011 $text = "User Name (Real Name)"; $regex = preg_match("/^(.*)\s\((.*)\)$/", $text, $matches); $username = $matches[1]; $realname = $matches[2]; 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.