如何在PHP中获取URL的最后两部分?

use*_*572 0 php string url search

我有这个网址:http://itutormaths.hub/home/hub/6/hello/world我想抓住你好和世界.

我该怎么做?

谢谢!

Com*_*eek 8

<?php

$url = 'http://itutormaths.hub/home/hub/6/hello/world';

$pathParts = explode( '/', parse_url($url, PHP_URL_PATH) );

$lastParts = array( array_pop($pathParts), array_pop($pathParts) );

var_dump($lastParts);
Run Code Online (Sandbox Code Playgroud)