0

I need to write multiple arrays into one variable, f.e:

$test= Yii::$app->request->get('Test', []);
$test1 = Yii::$app->request->get('Test1', []);
$test2 = Yii::$app->request->get('Test2', []);

If I have these 3 statements, I want to join in together by using just only 1 variable. Is it possible to do so?

Thanks for any help

4
  • You need to be more specific - give us some example of your desired output. Commented Jul 26, 2017 at 6:33
  • I don't know how to specify it more. I just simply want to write 1 variable instead of writing $test, $test1 and $test2, because it's repetetive. Commented Jul 26, 2017 at 6:39
  • But you said you want to join them. Join them how? Commented Jul 26, 2017 at 6:40
  • Em, maybe join is not correct word for it. F.e if I have $test1, $test2, and $test3 sentences, I need to write all 3 into 1 variable to not be repetetive Commented Jul 26, 2017 at 6:44

1 Answer 1

1

Use:

$test = Yii::$app->request->get();

You will get array with all your data.

Or if you want to specify indexes:

$test[] = Yii::$app->request->get('Test', []);
$test[] = Yii::$app->request->get('Test1', []);
$test[] = Yii::$app->request->get('Test2', []);
Sign up to request clarification or add additional context in comments.

2 Comments

But some of my data are from different tables. F.e test is from the table 'table1', 'test2' => table2, 'test3' => 'table3'. Do I will get the array with all my data with that one $test = Yii::$app->request->get();?
Yes, it will get all Your GET data

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.