Jump to content

How could I combine these arrays??


Scooby08

Recommended Posts

Hello.. I'm trying to figure out a way to combine these first two arrays to get the last array..

 

1st array:

Array
(
    [0] => zero
    [1] => one
    [2] => two
)

 

2nd array:

Array
(
    [0] => Array
        (
            [0] => test0
        )

    [1] => Array
        (
            [0] => test1
        )

    [2] => Array
        (
            [0] => test2
        )
)

 

The array I'm trying to get out of both:

Array
(
    [zero] => Array
        (
            [0] => test0
        )

    [one] => Array
        (
            [0] => test1
        )

    [two] => Array
        (
            [0] => test2
        )
)

 

 

Link to comment
https://forums.phpfreaks.com/topic/190205-how-could-i-combine-these-arrays/
Share on other sites

but thorpe code is working for you!

I have also tested it!

<?php

 

$a = array('zero','one','two');

 

$b = array(array('test0'),array('test1'), array('test2'));

 

echo '<pre>';

 

 

$a_val = array_values($a);

$b_val = array_values($b);

 

foreach ($a_val as $k=>$v)

{

$new[$v] = $b_val[$k];

}

 

print_r($new);

 

 

 

 

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.