Array
(
[0] => Array
(
[Access ID] => 12345
[Registration Date] => 2018-02-27
[First Name] => Damian
[Last Name] => Martin
[Flying Tour] =>
)
[1] => Array
(
[Access ID] => 12345
[Registration Date] => 2018-02-27
[First Name] => Damian
[Last Name] => Martin
[Flying Tour] => Yes going
)
[2] => Array
(
[Access ID] => 789456
[Registration Date] => 2018-03-27
[First Name] => Ricky
[Last Name] => Smith
[Flying Tour] =>
)
[3] => Array
(
[Access ID] => 789456
[Registration Date] => 2018-03-27
[First Name] => Ricky
[Last Name] => Smith
[Flying Tour] => Two way going
)
[4] => Array
(
[Access ID] => 987654
[Registration Date] => 2018-04-27
[First Name] => Darron
[Last Name] => Butt
[Flying Tour] =>
)
)
$results = [];
foreach($data as $input){
$isDuplicate = false;
foreach($results as $result){
if(
strtolower($input['First Name'])===strtolower($result['First Name']) &&
strtolower($input['Last Name'])===strtolower($result['Last Name']) &&
strtolower($input['Registration ID'])===strtolower($result['Registration ID']) &&
strtolower(!empty($input['Flying Tour']))
){
//a duplicate was found in results
$isDuplicate = true;
break;
}
}
//if no duplicate was found
if(!$isDuplicate) $results[]=$input;
}
Finding duplicate value and remove one of them and pick one. It does work for all except flying tour condition adding that does not return right output.
This should return this. I don't know where i'm going wrong please guide thank you once again Oh here what i expect this should be
Array
(
[0] => Array
(
[Access ID] => 12345
[Registration Date] => 2018-02-27
[First Name] => Damian
[Last Name] => Martin
[Flying Tour] => Yes going
)
[1] => Array
(
[Access ID] => 789456
[Registration Date] => 2018-03-27
[First Name] => Ricky
[Last Name] => Smith
[Flying Tour] => Two way going
)
[2] => Array
(
[Access ID] => 987654
[Registration Date] => 2018-04-27
[First Name] => Darron
[Last Name] => Butt
[Flying Tour] =>
)
)
Some changes are made please see