开发者

variable number of parameters from a url/paramname/valueparam in an array?

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 wi开发者_如何转开发th 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!


Yep the URI class provides this functionality in the form of

$this->uri->uri_to_assoc(n);

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

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜