sastro Posted April 2, 2011 Share Posted April 2, 2011 Hi, I need help with preg_replace all chars after last " - " . exp. string. my lovely wife - wake up Check Google ban tool - Check adsense ban tool - new tool Need result like this my lovely wife Check Google ban tool - Check adsense ban tool Thanks in advanced Quote Link to comment Share on other sites More sharing options...
.josh Posted April 2, 2011 Share Posted April 2, 2011 $string = "your string here"; $string = preg_replace('~\s*-[^-]*$~','',$string); This also removes space(s) before the last hyphen. If you don't want that then remove that \s* Quote Link to comment Share on other sites More sharing options...
sastro Posted April 2, 2011 Author Share Posted April 2, 2011 Thank you, thank you and thank you. Works like a charm.. You're the best... I can't found the solved button 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.