Answers for "merge two sequential arrays without duplicate values in php"

PHP
0

php combine 2 arrays keep duplicates

$arrKeys = array('str', 'str', 'otherStr');
$arrVals = array('1.22', '1.99', '5.17');
function foo($key, $val) {
   return array($key=>$val);
}

$arrResult = array_map('foo', $arrKeys, $arrVals);
Posted by: Guest on August-17-2020
0

Merge two arrays without duplicate values in PHP

<?php
$array1 = array("yellow", "red", "green", "orange", "purple");
$array2 = array("pink", "brown", "green", "orange", "red");
$array = array_unique(array_merge($array1, $array2));
print_r($array);
?>
Posted by: Guest on November-12-2021

Browse Popular Code Answers by Language