Combine 2 arrays of different length

后端 未结 4 1845
情深已故
情深已故 2021-01-26 16:12

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

4条回答
  •  礼貌的吻别
    2021-01-26 16:48

    Try this. loop the 2nd array and extract the value from array1 with using value of array2 as index for array1

    foreach ( $array2 as $arr2 ){
       $temp[]= $array[ $arr2 ];
    }
    return $temp;
    

提交回复
热议问题