gpt4 book ai didi

zend-framework - 在 Zend 中执行操作后获取所有参数?

转载 作者:行者123 更新时间:2023-12-04 16:27:54 28 4
gpt4 key购买 nike

当我在 Zend 中调用如下所示的路由器时:
coupon/index/search/cat/1/page/1/x/111/y/222
当我收到 $this->_params 时,在 Controller 内部,我得到一个数组:

array(
'module' => 'coupon',
'controller' => 'index',
'action' => 'search',
'cat' => '1',
'page' => '1',
'x' => '111',
'y' => '222'
)

但我只想得到:
array(
'cat' => '1',
'page' => '1',
'x' => '111',
'y' => '222'
)

你能告诉我一种获得所有 params的方法吗?就在 action 之后?

最佳答案

恕我直言,这更优雅,包括 Action 、 Controller 和方法键的变化。

$request = $this->getRequest();
$diffArray = array(
$request->getActionKey(),
$request->getControllerKey(),
$request->getModuleKey()
);
$params = array_diff_key(
$request->getUserParams(),
array_flip($diffArray)
);

关于zend-framework - 在 Zend 中执行操作后获取所有参数?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/7900490/

28 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com