I have two arrays one is self defined.
$fields = array( "first_name" => "test", "last_name" => "Test", "phone" =>"111-111-1111, "id" => 1234");
the other is grabbed from the first row of a csv file. which will return an array like so
$headers = array ("fname" => "test", "last_name" => "Test", "phone"=> "123-123-1234");
I then want to return an error if there is a key in $headers array doesn't match any of the keys in $fields array. Its okay if the keys in the $fields array aren't all present in the $headers array.
For example the two arrays above should return an error because the key fname does not exist in the $fields array but not because the id is missing in the $headers array.
I tried experimenting with if statements with multiple loops but I am looking for a better way I thought I could manipulate the array_diff method but have had no luck.
$dif_keys = array_diff($fields, $headers);
array_diff_key()instead.phoneandlast_nameare in both and so matches, you need to explain the criteria better.