PHP中斜线后从URL中获取两个单词
我需要从 URL 中获取两个词.例如,我有以下网址:
I need to get two words from an URL. So for example I have the following URL:
http://mydomain.com/alrajhi/invoice/108678645541
我只需要使用 PHP 就可以使用alrajhi"和数字108678645541".
I need to get with PHP only "alrajhi"and the number "108678645541" nothing else.
你能帮我吗?
非常感谢!!
推荐答案
$string = 'http://mydomain.com/alrajhi/invoice/108678645541';
$parse = parse_url($string);
$explode = explode('/', $parse['path']);
现在你有:
echo $explode[1]; // alrajhi
echo $explode[3]; // 108678645541
相关文章