Monday 3 September 2018
Subscribe to:
Post Comments (Atom)
$arr1 = array(1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12);
$arr2 = array(01=>123, 03=>123, 05=>123, 07=>123, 09=>123, 11=>123);
$results = array(01=>123, 02, 03=>123, 04, 05=>123, 06, 07=>123, 08, 09=>123, 10, 11=>123, 12);
$results = array_intersect_key($arr1 + $arr2, $arr2);
among other PHP functions as well as:for ($i=1; $i < count($arr1); $i++) {
if (isset($arr2[$i])) {
$arr3[] = $arr2[$i];
} else {
$arr3[] = $arr1[$i];
}
}
print_r($arr3);
$arr1 = array(1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12);
$arr2 = array(1=>123, 3=>123, 5=>123, 7=>123, 9=>123, 11=>123);
foreach ($arr1 as $key) {
$results[$key] = isset($arr2[$key]) ? $arr2[$key] : null;
}
$results = array_replace(array_fill_keys($arr1, null), $arr2);
Hello Friends! I am Ramana a part time blogger from Hyderabad.
0 comments:
Post a Comment