Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
我想合并两个重复的数组 例如, $n1 = array(0=>'foo', 1=>'bar', 2=>'baz'); $n2 = array(0=>'lorem', 1=>'ipsum', 2=>'foo'); 结果应该是,
$result = array(0=>'foo', 1=>'bar', 2=>'baz',3=>'lorem', 4=>'ipsum', 5=>'foo');
我在 PHP 中有任何可用的预定义函数
array_merge怎么样?它完全符合您的需要。
$array = array_merge($n1, $n2);