dongmei8209 2014-04-11 17:57
浏览 29
已采纳

parse_url make / store / cat1 / pro4 to / store / cat1

I have this url /store/cat1/pro4 I want it to remove the /pro4, so it becomes /store/cat1

Or

If I just could extract the /cat1 from the string

How can I do this?

  • 写回答

1条回答 默认 最新

  • dsfliu1129 2014-04-11 18:03
    关注

    Here is a way to do it by spliting the string:

    $url = "/store/cat1/pro4";
    list($path,$store,$category,$product) = explode("/",$url);
    
    echo $store;    // store
    echo $category; // cat1
    echo $product;  // pro4
    
    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?