Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/php/263.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Php 使用数组将参数传递给HMVC模块方法_Php_Arrays_Codeigniter_Parameter Passing_Hmvc - Fatal编程技术网

Php 使用数组将参数传递给HMVC模块方法

Php 使用数组将参数传递给HMVC模块方法,php,arrays,codeigniter,parameter-passing,hmvc,Php,Arrays,Codeigniter,Parameter Passing,Hmvc,当在Codeignitors中使用HMVC组件时,我们可以呈现这样的特定动作 echo modules::run('site/news/view', 1); 这里,1是发送到视图方法的参数 现在我有了一个参数数组,需要将其传递给函数 $params = array(1, "latest", "desc"); //suppose this are the parameters I received dynamically some how and dont knows its length 现

当在Codeignitors中使用HMVC组件时,我们可以呈现这样的特定动作

echo modules::run('site/news/view', 1);
这里,
1
是发送到视图方法的参数

现在我有了一个参数数组,需要将其传递给函数

$params = array(1, "latest", "desc"); //suppose this are the parameters I received dynamically some how and dont knows its length
现在,我需要将这些参数单独发送为

echo modules::run('site/news/view', 1, "latest", "desc");

与其他函数一样,
call\u user\u func\u array()。您应该按照函数已经运行的方式编写代码。如果它不能按您需要的方式工作,请在允许的情况下修改源代码,或者编写自己的版本,或者扩展主类以满足您的需要

我可以简单地回答这个问题,但这次我希望你也这么做。我之前已经回答了你的问题&我刚刚查看了你的个人资料,6个问题(1个已接受)0个答案,大多数问题没有你方面的意见。你似乎没有自己做任何事情

你依靠这个社区来完成你的工作,这太不公平了。因此,除非你向我展示你的一些作品,否则我拒绝回答。

我创建了一个“seo前端控制器”,我(残忍地)用这种方式解决了同样的问题

if( count($params) == 2 ) {
    echo modules::run( 'controller/method', $params[0], $params[1] );
} else if( count($params) == 3 ) {
    echo modules::run( 'controller/method', $params[0], $params[1], $params[2] );
}