<span>/*</span><span> * PHP按值合并数组 * </span><span>*/</span> <span>function</span> my_array_merge(&<span>$array1</span>, &<span>$array2</span><span>) { </span><span>$result</span> = <span>Array</span><span>(); </span><span>foreach</span>(<span>$array1</span> <span>as</span> <span>$key</span> => &<span>$value</span><span>) { </span><span>$result</span>[<span>$key</span>] = <span>array_merge</span>(<span>$value</span>, <span>$array2</span>[<span>$key</span><span>]); } </span><span>return</span> <span>$result</span><span>; }</span>