Arun Rama Balan.G
Arun Rama Balan.G

Reputation: 188

Assign one array values into another one array in for loop in php

I have an array like this

$arr1 = Array
(
    [0] => 0
    [1] => 0
    [2] => 0
    [3] => 1
    [4] => 1
    [5] => 1
    [6] => 0
)
$arr2 = Array
(
    [0] => 1
    [1] => 0
    [2] => 0
    [3] => 0
    [4] => 0
    [5] => 0
    [6] => 1
)

I want to create a new array with the values of a2 as keys in $arr1. My resultant array should be like this

$arr3 = Array
(
    [0] => $arr1 = Array
(
    [0] => 0
    [1] => 0
    [2] => 0
    [3] => 1
    [4] => 1
    [5] => 1
    [6] => 0
)
    [1] => $arr2 = Array
(
    [0] => 1
    [1] => 0
    [2] => 0
    [3] => 0
    [4] => 0
    [5] => 0
    [6] => 1
)
)

Note : All are in a for loop. Plz help me..

Upvotes: 1

Views: 411

Answers (1)

Shakti Singh
Shakti Singh

Reputation: 86386

$arr3= array($arr1, $arr2);

It is simple.

Upvotes: 2

Related Questions