php - Create an array of key difference using two array -
how can find key deference array using 2 arrays first array :
$array_1 = array('300','200','500');
second array :
$array_2 = array('500','300','200');
$array_2
generating applying rsort
$array_1
then want generate array of key comparing value of $array_1
, key of $array_2
.output array of
$key_array = ('1','2','0');
use array_flip()
on $array_2
convert keys values , vice versa. can find original keys.
$flip_2 = array_flip($array_2); $key_array = array_map(function($el) use ($flip_2) { return $flip_2[$el]; }, $array_1);
Comments
Post a Comment