closet geek Posted July 28, 2007 Share Posted July 28, 2007 Say I have these test strings: Test ThingPL324jbkbDSfNKnasdfdkjn324fNJFDjkn Another TestPL324jbkbDSfNKnasdfdkjn324fNJFDjkn and I want to remove anything that starts with PL* (including PL itself) so I'm left with: Test Thing Another Test How would I do that? Thanks. Quote Link to comment Share on other sites More sharing options...
closet geek Posted July 29, 2007 Author Share Posted July 29, 2007 Anyone? Quote Link to comment Share on other sites More sharing options...
hackerkts Posted July 29, 2007 Share Posted July 29, 2007 Hope this helps, $text = 'Test ThingPL324jbkbDSfNKnasdfdkjn324fNJFDjkn'; $explode = explode("PL", $text); $text = str_replace($explode[1], '', $text); echo $text; Quote Link to comment Share on other sites More sharing options...
closet geek Posted July 29, 2007 Author Share Posted July 29, 2007 Thanks for your reply! Unfortunately that outputs: "Test ThingPL" when I would like only "Test Thing" to be the output. Any ideas? ??? Quote Link to comment Share on other sites More sharing options...
corbin Posted July 29, 2007 Share Posted July 29, 2007 The explode example should work fine... Except I think it might need to be (and there's an extra step): $text = 'Test ThingPL324jbkbDSfNKnasdfdkjn324fNJFDjkn'; $explode = explode("PL", $text); $text = $explode[0]; echo $text; //Test Thing Quote Link to comment Share on other sites More sharing options...
closet geek Posted July 29, 2007 Author Share Posted July 29, 2007 The explode example should work fine... Except I think it might need to be (and there's an extra step): $text = 'Test ThingPL324jbkbDSfNKnasdfdkjn324fNJFDjkn'; $explode = explode("PL", $text); $text = $explode[0]; echo $text; //Test Thing Thank you! That works perfectly. 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.