Passing multiple values for same GET variable in URL

微笑、不失礼 提交于 2019-12-06 08:29:34

Using explode() is only reliable if the values of each tag will never contain whatever string it is you're exploding by (in this case ",").

I'd say it's safer to use tags[]=X&tags[]=Y.

you can urlencode(json_encode(yourData)), then on the server json_decode

this solution will work with any complex data you may need to pass, not just the simple one you have here.

i think the best solution is using json_encode(). But if you want to look nice (as a single string). You can encyrpt code to look like page?tags=HuH&ITBHjYF86588gmjkbkb. Simplest of doing it is

$tags = base64_encode(json_encode($tags_array));

I suggest using mod_rewrite to rewrite like www.website.com/tags/tag1-tag2-tag3 or if you want to use only php www.website.com/tags.php?tags=tag1-tag2-tag3. Using the '-' makes it searchengine friendly (as for tags is often useful) and is also not as commonly used as a comma (thinking of the tagging itself).

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!