Assuming that "http://" always appears twice on $string, search the string for "http://" backwards using strripos. If the search succeeds, you'll know the start_index of the "http://" you want to remove (and you know the length of course). Now you can use substr to extract everything that goes before and after the chunk you want remove.