How to get params in url , and it is array? yii2

Noobs To be Pro Addict picture Noobs To be Pro Addict · Aug 15, 2015 · Viewed 10.2k times · Source

I have url like this

 http://localhost/belajar4/web/index.php?r=data%2Fsingle&id=2&DataSearch[TANGGAL]=2015-08-04&DataSearch[TANGGAL_SELESAI]=2015-08-12 

And I want to get DataSearch['Tanggal'] dan DataSearch[TANGGAL_SELESAI]

I have tried for id with

 Yii::$app->request->queryParams['id'] 

And it was success for it, but not with DataSearch['Tanggal']

When I try for DataSearch['Tanggal'] the error is

 Undefined index: DataSearch[TANGGAL] 

I think it should have easy to answer but i am newbie for yii2 and i didnt find the solution yet

Answer

Jakuje picture Jakuje · Aug 15, 2015

You can get them from array like this:

Yii::$app->request->queryParams['DataSearch']["TANGGAL_SELESAI"]
Yii::$app->request->queryParams['DataSearch']["TANGGAL"]