jerry666
jerry666

Reputation: 19

how can create new array from multiple array in codeigniter?

Two array given bellow , i want to first array first key and with second array second key and create new array.

 [animals1] => Array
        (
            [0] => Horse
            [1] => Dog1
            [1] => Cat
        )
[animals2] => Array
        (
            [0] => Cow
            [1] => Dog2
            [1] => Rat
        )

i need array given bellow.

[0] => Array
        (
            [0] => Horse
            [1] => Cow
        ),
[1] => Array
        (
            [0] => Dog1
            [1] => Dog2
        ),
[2] => Array
        (
            [0] => Cat
            [1] => Rat
        )

Any Array related knowledge please share here ....

Upvotes: -1

Views: 46

Answers (1)

Vishnu Prajapati
Vishnu Prajapati

Reputation: 46

You Can Try using array_map() function.

$data['animalses'] = array_map(null, $animals1, $animals2); 

Upvotes: 0

Related Questions