UNPKG

phpjs

Version:

php.js offers community built php functions in javascript

62 lines (48 loc) 1.77 kB
<!-- Generated by Rakefile:build --> <strong> Demosthenes Koptsis </strong> on 2012-07-17 23:34:20 <br /> This code overwrite keys with the same index. Does not preserve these values. Value 5 has key 0 same with value 10. The result is the value 10 overwrites 5. <hr /> <strong> Demosthenes Koptsis </strong> on 2012-07-16 18:07:20 <br /> There is a bug i think. <pre><code> arr1 = {'color': {'favourite': 'read'}, 0: 5}; arr2 = {0: 10, 'color': {'favorite': 'green', 0: 'blue'}}; Result = {0=10, 'color':{'favourite': 'read', 'favorite':'green', 0='blue'}} </code></pre> value: 5 is lost! <hr /> <strong> <a href="http://an3m1.com/" rel="nofollow">????? ????</a> </strong> on 2012-04-10 09:55:43 <br /> If I might —perhaps you should consider adding a few images. I don’t mean to disrespect what you’ve said ; its very enlightening, indeed. However, I think would respond to it more positively if they could be something tangible to your ideas <hr /> <strong> Shannon </strong> on 2010-02-12 21:23:36 <br /> Sorry I included the script tags without thinking. <pre><code> var arr1 = {'color': {'favorite': 'red'}, 0: 5}, arr2 = {0: 10, 'color': {'favorite': 'green', 0: 'blue'}}; result = array_merge_recursive(arr1, arr2); // result = {0:10,'color':{0:'blue','favorite':'green'}} <hr /> <strong> Shannon </strong> on 2010-02-12 21:17:39 <br /> Am I doing some thing wrong? Using your example I get the following: <pre><code>&lt;script&gt; var arr1 = {'color': {'favorite': 'red'}, 0: 5}, arr2 = {0: 10, 'color': {'favorite': 'green', 0: 'blue'}}; result = array_merge_recursive(arr1, arr2); // result = {0:10,color:{0:blue,favorite:green}} &lt;/script&gt;<pre><code> I downloaded the full package so I should have all the dependencies. <hr />