- substr: documentation ( source)
- urlencode: documentation ( source)
- parse_url: documentation ( source)
<?php
$url = "http://carkva-gazeta.org/римско-католическая-церковь/";
// in case it is https, we don't want to hardcode http
$scheme = parse_url($url, PHP_URL_SCHEME);
$host = parse_url($url, PHP_URL_HOST);
$encodedPath = urlencode(substr(parse_url($url, PHP_URL_PATH), 1, -1));
$encodedUrl = $scheme . "://" . $host . "/" . $encodedPath . "/";
echo $encodedUrl;