我的网站就像?dir = / friends / pending,我想知道我是否只能获得字符串中的“朋友”部分?
到目前为止我的尝试
//I got the "pending" part by below...
$val = substr( $_GET['a'], strrpos( $_GET['a'], '/' )+1 );
//I tried getting "friends" with this but it didnt give me what i wanted..
$val2 = substr( $_GET['a'], strrpos( $_GET['a'], '/' )- $val -2 );
答案 0 :(得分:0)
您可以使用PHP的explode
:
$pieces = explode('/', $_GET['a']);
# $pieces[1] = 'friends'