Php 如何在yii2中返回数组值?

Php 如何在yii2中返回数组值?,php,arrays,yii2,Php,Arrays,Yii2,我的查看代码是: <?= $form->field($model, 'ReportSelection[]')->dropdownlist(['1' => 'Channel1', '2' => 'channel2','3'=>'channel3','4'=>'channel4'],['multiple'=>'multiple']); ?> 我的行动职能是: public function actionSelectedreport($repor

我的查看代码是:

<?= $form->field($model, 'ReportSelection[]')->dropdownlist(['1' => 'Channel1', '2' => 'channel2','3'=>'channel3','4'=>'channel4'],['multiple'=>'multiple']); ?>
我的行动职能是:

public function actionSelectedreport($reportoptions,$reportselection,$fromdate,$todate)
我需要
$reportselection
作为参数用于:

foreach($reportselection as $i)   
{
    $selectlist = $selectlist . 'Channel'.$i.'Value,';
}

默认情况下,所有操作参数都是标量。如果需要接受数组,则应在方法签名中明确指定此类型:

public function actionSelectedreport($reportoptions, array $reportselection, $fromdate, $todate)

请解释清楚。您的问题我完全不清楚PortSelection[]无法使用?如何返回数组?如何在函数中传递数组作为参数?表单字段在表单中?是否要将表单值传递给相对操作?请说明更好的方法当然需要将值传递给操作在您的操作中,您可以使用Yii::$app->request->post()获取表单数据
public function actionSelectedreport($reportoptions, array $reportselection, $fromdate, $todate)