简体   繁体   English

从网址段获取标签

[英]Get tags from URL segment

I am developing an web app using Codeigniter. 我正在使用Codeigniter开发一个Web应用程序。 In this app I got a tag based search. 在这个应用程序中,我得到了一个基于标签的搜索。 I need people to be able to use an URL where the tags are predefined and then do a search using them. 我需要人们能够使用预定义标签的URL,然后使用它们进行搜索。

Like this: 像这样:

http://example.com/search/tags/tag1/tag2/tag3

How can I get all segments (tags) efter the tags segment? 如何在标签细分之后获取所有细分(标签)?

Thankful for all input! 感谢所有输入!

我猜你想在控制器中使用

$tags = $this->uri->uri_to_assoc();

you can do this with function explode(): 你可以使用explode()函数来做到这一点:

$url = "http://example.com/search/tags/tag1/tag2/tag3";

list($url_part, $segments) = explode("/tags/", $url);

$tags_array = explode("/", $segments);

Try this:- 尝试这个:-

         <script type="text/javascript">
        jQuery(document).ready(function(){

        var url = http://example.com/search/tags/tag1/tag2/tag3;

parts = url.split('/');
alert(parts[1]);
   ​});
</script>

You have to fetch array values according to u. 您必须根据u获取数组值。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM