Path: csiph.com!v102.xanadu-bbs.net!xanadu-bbs.net!feeder.erje.net!eu.feeder.erje.net!fu-berlin.de!uni-berlin.de!individual.net!not-for-mail From: "J.O. Aho" Newsgroups: comp.lang.php Subject: Re: how to join two arrays? Date: Sat, 03 May 2014 22:07:21 +0200 Lines: 35 Message-ID: References: <1ma4780alja8r$.a7gtdehqwehf$.dlg@40tude.net> Mime-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit X-Trace: individual.net pdWb20VrEd1QTVV66cp3awyoO9MTUDMu63fME7089Q3jwrL2t5 Cancel-Lock: sha1:rMHPnZ8g2mNyS2SzM7MI03UZxUc= User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:24.0) Gecko/20100101 Thunderbird/24.2.0 In-Reply-To: <1ma4780alja8r$.a7gtdehqwehf$.dlg@40tude.net> Xref: csiph.com comp.lang.php:13498 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: 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