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. Link to comment https://forums.phpfreaks.com/topic/62244-solved-help-removing-characters-after-two-letters-have-occurred/ Share on other sites More sharing options...
closet geek Posted July 29, 2007 Author Share Posted July 29, 2007 Anyone? Link to comment https://forums.phpfreaks.com/topic/62244-solved-help-removing-characters-after-two-letters-have-occurred/#findComment-310024 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; Link to comment https://forums.phpfreaks.com/topic/62244-solved-help-removing-characters-after-two-letters-have-occurred/#findComment-310150 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? ??? Link to comment https://forums.phpfreaks.com/topic/62244-solved-help-removing-characters-after-two-letters-have-occurred/#findComment-310221 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 Link to comment https://forums.phpfreaks.com/topic/62244-solved-help-removing-characters-after-two-letters-have-occurred/#findComment-310289 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. Link to comment https://forums.phpfreaks.com/topic/62244-solved-help-removing-characters-after-two-letters-have-occurred/#findComment-310381 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.