-1

http://www.mywebsite/product-tag/animal/

如何在没有反斜杠的情况下以这样的大写字母呼应动物:

动物

4

3 回答 3

0
$link = 'http://www.mywebsite/product-tag/animal/';
$parts = explode( '/', $link );
echo(strtoupper($parts[4]));

如果要自动搜索,则需要使用 preg_match。

于 2013-08-22T06:41:34.747 回答
0
<?php
$string = 'http://www.mywebsite/product-tag/animal/';
$urlparts = explode("/", $string);

$animal = ($string[strlen($string)-1] == '/'? $urlparts[count($urlparts)-2] : end($urlparts));
echo strtoupper($animal);
?>
于 2013-08-22T06:45:57.803 回答
0

其实我只是想通了

$r = $_SERVER['REQUEST_URI']; 
$r = explode('/', $r);
$r = array_filter($r);
$r = array_merge($r, array()); 

$endofurl = $r[1];
echo $endofurl;
于 2013-08-22T06:49:09.320 回答