<?php
// user input
$url = 'http://www.example.com/category/website/wordpress/wordpress-security/';
$url0 = 'http://www.example.com/';
$url1 = 'http://www.example.com/category/';
$url2 = 'http://www.example.com/category/website/';
$url3 = 'http://www.example.com/category/website/wordpress/';
// print_r(parse_url($url));
// echo parse_url($url, PHP_URL_PATH);
$removeprotocols = array('http://', 'https://');
echo '<br>' . str_replace($removeprotocols,"",$url0);
echo '<br>' . str_replace($removeprotocols,"",$url1);
echo '<br>' . str_replace($removeprotocols,"",$url2);
echo '<br>' . str_replace($removeprotocols,"",$url3);
?>