I have an array with 100 values(array1). I have another array with 8 values(array2). I want to take the values from array2 and use them as keys and extract the values in array1
you can use below code
function array_combine2($arr1, $arr2) {
foreach($arr2 as $val){
$arr3[] = $arr1[$val];
}
return $arr3;
}
For inctanse,
$arr1['x'] = 2;
$arr1['y'] = 3;
$arr1['z'] = 4;
$arr2[0] = 'x';
$arr2[1] = 'y';
$arr2[2] = 'z';
the above function will return the below as resbonse
$arr3[0] = 2;
$arr3[1] = 3;
$arr3[2] = 4;