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
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);

 

 

 

 

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.