FUDforum
Fast Uncompromising Discussions. FUDforum will get your users talking.

Home » Imported messages » comp.lang.php » how to join two arrays?
Show: Today's Messages :: Polls :: Message Navigator
Return to the default flat view Create a new topic Submit Reply
Re: how to join two arrays? [message #185710 is a reply to message #185704] Sat, 03 May 2014 20:07 Go to previous messageGo to previous message
J.O. Aho is currently offline  J.O. Aho
Messages: 194
Registered: September 2010
Karma:
Senior Member
On 03/05/14 19:25, richard wrote:
> I am building an array by scannning ten directories.
> With each scanned directory, the output is stored in one array.
> How do I properly join that array with a second array?
>
> Without duplicate keys!
>
> Array_merge works fine but keys are duplicated.

Keys are always unique, see example:


<?php

$a1 = array("a" => 1, "b" => 2, "c" => 3);

$a2 = array("a" => 10, "d" => 4, "e" => 5);

$a3 = array_merge($a1, $a2);

var_dump($a1);
var_dump($a2);
var_dump($a3);

echo $a3["a"]."\n";

?>

If you haven't named the cells, then it will just merge the arrays
(append one after the other).


--

//Aho
[Message index]
 
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Previous Topic: count() problem
Next Topic: part two same issue - unwanted empty values in array
Goto Forum:
  

-=] Back to Top [=-
[ Syndicate this forum (XML) ] [ RSS ]

Current Time: Tue Nov 26 11:23:58 GMT 2024

Total time taken to generate the page: 0.05216 seconds