我只想要第一个数组非空索引与具有相同索引的第二个数组,这意味着在这种情况下,用第二个数组索引 0 替换第一个数组索引 0:
$all_images => array:2 [ 0 => "00fb319e3af47a5600d39248ad5ea9c2.png"
1 => null ]
$images => array:2 [ 0 => "1508159073atouch-q12-tablet-new-white-color-27-09-2017.png"
1 => "1508159073atouch-q12-tablet-new-white-color-30-07-2017.png" ]
结果:
$New_images => array:2 [ 0 => "00fb319e3af47a5600d39248ad5ea9c2.png"
1 => "1508159073atouch-q12-tablet-new-white-color-30-07-2017.png" ]
过滤掉空值并添加(两个数组的并集):
$New_images = array_filter($all_images) + $images;
本文收集自互联网,转载请注明来源。
如有侵权,请联系[email protected] 删除。
我来说两句