我有这个url/store/cat1/pro4,我想让它删除/pro4,所以它变成/store/cat1
或
如果我能从字符串中提取/cat1
我该怎么做?
这里有一种通过拆分字符串来实现的方法:
$url = "/store/cat1/pro4";
list($path,$store,$category,$product) = explode("/",$url);
echo $store; // store
echo $category; // cat1
echo $product; // pro4