PHP: remove `http://` from link title

后端 未结 7 1425
终归单人心
终归单人心 2020-12-31 17:34

I have a string that looks like:

$string = \'http://google.com\';

How can I remove the http:

7条回答
  •  一整个雨季
    2020-12-31 18:04

    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.

提交回复
热议问题