Concat Column name not working

Hello Dear Yii2 Developers!

I have a issue with fetch table column name. I want to fetch first column name "custom1" form field and check its value,if it is is not null then fetch next column name "custom2", I have 10 columns custom1 to custom10 in one filed;

This is my logic:




                      $model = User::find()->where(['id' => $id])->orderBy('id')->one();

                        for($i=1; $i<10; $i++){

				

				if($model->custom.$i == ""){

					$model->id= $id;

					$model->custom.$i = $title;

					$model->save();	

					break;

				}

			

			}

                      

but it show me this error:

"Unknown Property User::custom", at this line = if($model->custom.$i == ""){

why not concatenation working? e.g. $model->custom.$i


 $model = User::find()->where(['id' => $id])->orderBy('id')->one();     

                    for($i=1; $i<10; $i++){                           

                                      $customer = "custom".$i; if($model->$customer == ""){     

                                    $model->id= $id;                                         $model->$customer = $title;    

                                     $model->save();                                          break;                                 }                                                  }

Declare as a Variable and Use it.

Thank you so much, it is working.