i try to get the "oldest person" in my example address book.
This is the address book array:
Array
(
[0] => Array
(
[Firstname] => Bill
[Lastname] => McKnight
[Gender] => Male
[Birthday] => 16/03/77
)
[1] => Array
(
[Firstname] => Paul
[Lastname] => Robinson
[Gender] => Male
[Birthday] => 15/01/85
)
[2] => Array
(
[Firstname] => Gemma
[Lastname] => Lane
[Gender] => Female
[Birthday] => 20/11/91
)
[3] => Array
(
[Firstname] => Sarah
[Lastname] => Stone
[Gender] => Female
[Birthday] => 20/09/80
)
[4] => Array
(
[Firstname] => Wes
[Lastname] => Jackson
[Gender] => Male
[Birthday] => 14/08/74
)
)
With my code I get always the last array..
$oldestPerson = 0;
for($i=0; $i<count($persons);$i++){
if($persons[$i]['Birthday'] > $persons[$i+1]['Birthday']){
$oldestPerson = $persons[$i];
}
}
print_r($oldestPerson);
How can I compare correctly the birthdays?