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

Home » Imported messages » comp.lang.php » array_merge vs just doing it
Show: Today's Messages :: Polls :: Message Navigator
Return to the default flat view Create a new topic Submit Reply
Re: array_merge vs just doing it [message #170288 is a reply to message #170287] Wed, 27 October 2010 01:17 Go to previous messageGo to previous message
Jerry Stuckle is currently offline  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
==================
[Message index]
 
Read Message
Read Message
Read Message
Previous Topic: Php windows system(whois) not working
Next Topic: Study Abroad Scholarship For Study in Australia...
Goto Forum:
  

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

Current Time: Thu Nov 14 05:20:52 GMT 2024

Total time taken to generate the page: 0.08268 seconds