zintani Posted September 20, 2011 Share Posted September 20, 2011 Hello, Thanks to the members of the forum, I was able to make a good process. Now I am trying to delete a specific string of words, for example: $string = "My ambition is to become a professional php programmer. This ambition in my stage could be impossible but with persistent and commitment nothing is impossible. So I wish good luck for everyone." ; I would lke to know if it is possible to delete "nothing is impossible" and the following words no matter what are these words. In this example "So I wish good luck for everyone.". Quote Link to comment https://forums.phpfreaks.com/topic/247494-removing-a-substring/ Share on other sites More sharing options...
trq Posted September 20, 2011 Share Posted September 20, 2011 If the string is static like that you don't need regex, take a look at substr. Quote Link to comment https://forums.phpfreaks.com/topic/247494-removing-a-substring/#findComment-1270914 Share on other sites More sharing options...
zintani Posted September 20, 2011 Author Share Posted September 20, 2011 Thanks thorpe, I think I didn't explain my question well. The question is if there is another string for example: $string1 = "My ambition is to become a professional php programmer. This ambition in my stage could be impossible but with persistent and commitment nothing is impossible. So I wish good luck for everyone." ; $string2 = "My ambition is to become a professional php programmer. I started learning php last year and It was php server side part and now I am working on regex part. This ambition in my stage could be impossible but with persistent and commitment nothing is impossible. So I wish good luck for everyone." ; and for both of them I need to start deleting from nothing is impossible. Quote Link to comment https://forums.phpfreaks.com/topic/247494-removing-a-substring/#findComment-1270928 Share on other sites More sharing options...
trq Posted September 20, 2011 Share Posted September 20, 2011 Then use strpos to locate the position required by substr. Quote Link to comment https://forums.phpfreaks.com/topic/247494-removing-a-substring/#findComment-1270933 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.