Re: array_merge vs just doing it [message #170288 is a reply to message #170287] |
Wed, 27 October 2010 01:17 |
Jerry Stuckle
Messages: 2598 Registered: September 2010
Karma:
|
Senior Member |
|
|
On 10/26/2010 7:13 PM, Brian Smither wrote:
> I've studied array_merge and I know what it does regarding disparate
> key/value pairs.
>
> But what is the "strategy" of using array_merge when just assigning
> key/values to the array would work just as well?
>
> Ex.1:
>
> // Existing array
> $lang['front']['area1']="This is prime.";
> $lang['front']['area2']="This is sub-prime.";
>
> // New elements
> $modd['front']['loc3']="This is new.";
> $modd['front']['loc4']="This is new, too.";
>
> // merge the two
> $lang = array_merge($lang,$modd);
>
>
> Ex.2:
>
> // Existing array
> $lang['front']['area1']="This is prime.";
> $lang['front']['area2']="This is sub-prime.";
>
> // New elements
> $lang['front']['loc3']="This is new.";
> $lang['front']['loc4']="This is new, too.";
>
> // it just is
>
>
>
>
array_merge() is used when you have two different arrays containing data
already, i.e. from function calls, not when you're generating an array.
--
==================
Remove the "x" from my email address
Jerry Stuckle
JDS Computer Training Corp.
jstucklex(at)attglobal(dot)net
==================
|
|
|