php - Compare two multidimensional Associative arrays -
i've been trying hours now. have 2 multidimensional arrays.
$newdata ( [0] => array( [id] => 1 [name] => john [sex] => male ) [1] => array( [id] => 2 [name] => kenny [sex] => male ) [2] => array( [id] => 3 [name] => sarah [sex] => female ) [3] => array( [id] => 4 [name] => george [sex] => male ) ) $olddata ( [0] => array( [id] => 3 [name] => sarah [sex] => female ) [1] => array( [id] => 4 [name] => george [sex] => male ) [2] => array( [id] => 5 [name] => peter [sex] => male ) [3] => array( [id] => 6 [name] => lexi [sex] => female ) )
if name in $olddata
matched $newdata
need fetch id of array without using more loops
you want use array_search()
which can return key of array find match in.
eg
$key = array_search('$array1['name']', $array2);
Comments
Post a Comment