RE: Problem with arrays

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



From: virtualsoftware@xxxxxxxxx [mailto:virtualsoftware@xxxxxxxxx] 

> Hi,
> I have 2 arrays:
> 
> Array ( 
>            [0] => Array (
>                                 [0] => 28 
>                                 [1] => Music
>                               ) 
>             [1] => Array ( 
>                                  [0] => 5 
>                                  [1] => Books 
>                               ) 
>            )
> 
> and 
> 
> Array ( 
>            [0] => aaa
>            [1] => bbb
>            )
> 
> I want to join this two array and the result must be loke this: 
> 
> Array ( 
>            [0] => Array (
>                                 [0] => 28 
>                                 [1] => Music
>                                 [2] => aaa
>                               ) 
>             [1] => Array ( 
>                                  [0] => 5 
>                                  [1] => Books
>                                  [2] => bbb 
>                               ) 
>            )
> 
> Thanks in advance for your help

In this specific example, I think this would work:

<?
for ($i = 0; $i < count($second_array); $i++) {
	array_push($first_array[$i], $second_array[$i]);
}
?>

That's not terribly flexible, though. Is this used in a more generalized
sense, or is it just this specific instance?

-- 
Mike Johnson             Smarter Living, Inc.
Web Developer            www.smartertravel.com
mike@xxxxxxxxxxxxxxxxx   (617) 886-5539

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



[Index of Archives]     [PHP Home]     [Apache Users]     [PHP on Windows]     [Kernel Newbies]     [PHP Install]     [PHP Classes]     [Pear]     [Postgresql]     [Postgresql PHP]     [PHP on Windows]     [PHP Database Programming]     [PHP SOAP]

  Powered by Linux