I am developing an web app using Codeigniter. 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.
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():
$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.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.