Keyur Keyur - 1 month ago 17
PHP Question

remove http and https from string in php

I have several urls like,

https://example.com/

http://example.com/


I only want "example.com" as string

And I want to remove the


https:// and http://


So I have taken array like this,

$removeChar = ["https://", "http://", "/"];


What is the proper way to remove these?

Answer

This worked for me,

$http_referer = str_replace($removeChar, "", "https://example.com/");