Passing multiple optional parameter/value pairs with user defined pair order

人盡茶涼 提交于 2019-12-04 19:59:41

You can use the _remap function on the controller.

function _remap( $method, $params )
{
    $map = array();
    for( $i = 1; $i < count( $params ); $i = $i + 2 )
    {
        $map[$params[$i-1]] = $params[$i];
    }

    if( $method[0] != '_' && method_exists( $this, $method ))
        return $this->$method( $map );
}

If you want to use it across all your controllers, you would be better to write a custom controller to extend CI_controller with this function, and have all your controllers extend that.

AlunR

I'd pass all the parameters as 1 string with separators eg. /username|alunr#category|99 etc. and find the values from there using php's explode() function.

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