The way of adding array in PHP -
I'm testing PHP (5.4.4) for some code in apache (2.2.22).
I wonder how PHP actually works to parse the code given below.
& lt ;? Php $ x = array ('st1' = & gt; 'gd1', 'st2' = & gt; 'gd2'); $ Y = array ('st1' => gt; t1 '' whistle 3 '=> gt;' t3 '); $ Z = $ x + $ y; Var_dump ($ z);
Result
array (3) {["st1"] = & gt; String (3) "GD1" ["st2"] = & gt; String (3) "gd2" ["st3"] = & gt;
But how does this work?
For example (I have been guessed): $ x is first parsed and added to $ z, while $ parsing Y, the PP interpreter thinks the key 'ST1' exists (Which means the priority of $ x is more than $ y), and does not override it and add 'st3' and try not to assume it.
Just want to make sure I have misunderstood it ...
< P> If the keys are numeric, then all the values will appear in the new array. If the keys are string, duplicate will overwrite the previous events.
Also see:
Comments
Post a Comment