在Yii :: app() - > request-> post中设置多维数组

I am trying to set multi-dimensional array in Yii post:

Yii::app()->request->post(['PaymentMethodForm'][$_POST['PaymentOptionsForm']['payment_option']]['jazzcash_phone'], $phoneNumber);

to replace traditional $_POST.

$_POST['PaymentMethodForm'][$_POST['PaymentOptionsForm']['payment_option']]['jazzcash_phone'] = $phoneNumber;

$_POST code works fine but Yii post doesn't.

I have to replace all $_POST with Yii post.

Yii::app()->request->post() is GETTING value, with default fallback. It is not setting anything. If You need to populate $_POST array, You should use it directly. More info about request: http://www.yiiframework.com/doc-2.0/guide-runtime-requests.html

Your line Would evaluate to:

$name = $request->post('name', '');
// equivalent to: $name = isset($_POST['name']) ? $_POST['name'] : '';

However, because You are not assigning value to any variable, it does nothing.