ghostwalkz Posted February 17, 2009 Share Posted February 17, 2009 I have a string: $string = "somestuffthatchanges.somemorestuffthatchanges"; How can I strip everything before the first occurence of the period so it leaves me with just 'somemorestuffthatchanges'? Link to comment https://forums.phpfreaks.com/topic/145495-string-question-help/ Share on other sites More sharing options...
premiso Posted February 17, 2009 Share Posted February 17, 2009 explode $string = "somestuff.otherstuff"; list(, $string) = explode(".", $string); echo $string; Link to comment https://forums.phpfreaks.com/topic/145495-string-question-help/#findComment-763854 Share on other sites More sharing options...
ghostwalkz Posted February 17, 2009 Author Share Posted February 17, 2009 That almost works, but.. if my string has 2 periods eg: $string = "somestuff.morestuff,finalstuff"; You solution only returns 'morestuff' whereas I need 'morestuff.finalstuff' If that makes any sense? Thanks for the help BTW! ;-) Link to comment https://forums.phpfreaks.com/topic/145495-string-question-help/#findComment-763864 Share on other sites More sharing options...
premiso Posted February 17, 2009 Share Posted February 17, 2009 $string = "test.test.test.s"; $string = strstr($string, "."); echo $string; To remove the initial period you can make use of substr. Link to comment https://forums.phpfreaks.com/topic/145495-string-question-help/#findComment-763869 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.