Example user input
http://example.com/
http://example.com/topic/
http://example.com/topic/cars/
http://www.example.com/topic/questions/
I want a PHP function to make the output like
example.com
example.com/topic/
example.com/topic/cars/
www.example.com/topic/questions/
You should use an array of “disallowed” terms and use
strposandstr_replaceto dynamically remove them from the passed-in URL: