Heim >Backend-Entwicklung >PHP-Tutorial >php 按列值合并数据,php合并数据_PHP教程
<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>