D
D
damarkuzz2020-05-04 14:47:22
PHP
damarkuzz, 2020-05-04 14:47:22

How to select the last part of a link via PHP?

How can I make the given PHP code output only the last part of the current page link?

For example, the link of the current page site.ru/alias/path/cut-me
Required to display only cut-me

<?php 
  $url = $_SERVER['REQUEST_URI'];
  $url = explode('?', $url);
  $url = $url[0]; 
  echo $url; 
?>

Answer the question

In order to leave comments, you need to log in

1 answer(s)
D
DevMan, 2020-05-04
@damarkuzz

https://www.php.net/manual/ru/function.pathinfo.php
https://ideone.com/pr34FY

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question