How do I remove http, https and slash from user input in php

后端 未结 10 2101
不思量自难忘°
不思量自难忘° 2020-11-29 04:30

Example user input

http://domain.com/
http://domain.com/topic/
http://domain.com/topic/cars/
http://www.domain.com/topic/questions/

I want

10条回答
  •  天命终不由人
    2020-11-29 04:55

    You could use the parse url Functionality of PHP. This will work for all Protocols, even ftp:// or https://

    Eiter get the Protocol Component and substr it from the Url, or just concatenate the other Parts back together ...

    http://php.net/manual/de/function.parse-url.php

提交回复
热议问题