数组中 url/paramname/valueparam 的参数数量可变?
基本上我想读取数组中的 url 参数,因此查找参数不依赖于它们在 url 中的位置
我有一个用于搜索的 url controller/action/paramA/valueparamA/paramB/valueparamB
这些参数是可选的:我有直接的 url,其中包含搜索参数,
以便从 url 读取参数,我们必须使用 action(valueparamA, valueparamB) 但对我来说这似乎很僵化 我想按参数名称读取参数,而不是按参数在 url 中的位置读取!
所以我可以有不同的网址,就像
urlA = controller/action?paramA=valueA
*(or controller/action/paramA/valueA)*
urlB controller/action?paramB=valueB
我可以使用相同的操作一样,就像我们使用带有 $_POST 数组的表单一样(当直接网址参数时,它和 $_GET[} 似乎总是空的) 形式一样,
最好的办法是将所有参数放在一个数组中[paramname=>paramvalue],就像我不想要的 您可以对不同的参数使用不同的操作! :)
我看到的最好的方法是在类似数组的参数上使用 juste :
controller/action/array[paramname=>paramvalue]
(将数组作为 url 参数传递< /a>) 但这似乎使一些基本的事情变得复杂: 只需像每个框架都知道的那样读取正常的 url 参数:)
url?nameparam=valueparam&...
希望有一个解决方案! 我开始非常喜欢 ci 的轻便和快速,但有时(比如扩展模型)它似乎有点“僵化”;)
提前考虑任何想法!
basicly I would like to read url params in an array so finding params don't depend on their place in url
I have a url for seach with controller/action/paramA/valueparamA/paramB/valueparamB
theses params are optional : I have direct url with search params inside
to read params from url we have to use action(valueparamA, valueparamB)
but for me it seems really rigid
I want to read parameters by their name, not by their place in url!
so I can have different urls like
urlA = controller/action?paramA=valueA
*(or controller/action/paramA/valueA)*
urlB controller/action?paramB=valueB
than I can use with the same action, like we do with a form with $_POST array (it and $_GET[} seems always empty when direct url params)
the best would be to have all parameters in an array[paramname=>paramvalue] like in a form
what I DON'T want is tu use differents actions for different parameters possibles! :)
the best I saw was to use juste on array like parameter :
controller/action/array[paramname=>paramvalue]
(passing arrays as url parameter)
but it seems to complicate something basic :
just read the normal url parameters like every framework knows :) with
url?nameparam=valueparam&...
hope there is a solution !
I begin tor eally like the light and quick of ci but sometimes (like for extending model) it seems a little "rigid" ;)
think in advance for any idea!
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
是的,URI 类以以下形式提供此功能:
这将返回一个包含所有参数的数组(键和值必须在 URL 中定义)。
完整的详细信息可以在 Codigniter 用户指南中找到:
http://codeigniter.com/user_guide/libraries/ uri.html
Yep the URI class provides this functionality in the form of
This returns an array containing all parameters (keys and values must be defined in the URL).
Full details can be found on the Codigniter Userguide:
http://codeigniter.com/user_guide/libraries/uri.html