For example, the final effect of {code...} is as follows: {code...}. how can this algorithm be implemented? Example:
$ Arr = array ('000000' => 'flammulina velutipes ''000000' => 'Silver mushroom '); $ arr2 = array ('65' => 'white radish '67' => 'Black radish '84' => 'yellow radish '100' => 'Silver mushroom'' 90' => 'radish '000000' => 'mushroom ');
The final effect is as follows:
$ Arr3 = array ('20140901' => 'flammulina velutipes '20160301' => 'Silver needle mushroom '65' => 'white radish '67' => 'Black radish'' 84 '=> 'radish '90' => 'radish ');
How can this algorithm be implemented?
Reply content:
Example:
$ Arr = array ('000000' => 'flammulina velutipes ''000000' => 'Silver mushroom '); $ arr2 = array ('65' => 'white radish '67' => 'Black radish '84' => 'yellow radish '100' => 'Silver mushroom'' 90' => 'radish '000000' => 'mushroom ');
The final effect is as follows:
$ Arr3 = array ('20140901' => 'flammulina velutipes '20160301' => 'Silver needle mushroom '65' => 'white radish '67' => 'Black radish'' 84 '=> 'radish '90' => 'radish ');
How can this algorithm be implemented?
The problem has been closed and I wrote it myself. I thought it was complicated when I asked the question. after the problem was solved, I realized it was so simple that I posted the code:
foreach ($arr2 as $key => $value) { if(!in_array($value, $arr)) { $arr[$key] = $value; }}var_dump($arr);
return($arr + $arr2);