Friday, 6 September 2013

Booleans not returning correctly

Booleans not returning correctly

My task is to be able to the an someones birthday as an argument and
return there age and whether or not its there birthday in this specific
way
<?php
function getBirthDate($birthdate)
{
$today =getdate();
$day =array($today["mon"], $today["mday"]);
$newBday = str_replace("/",",",$birthdate);
$birthDate = explode(",",$newBday);
$monthDay = array($birthDate["0"],$birthDate[1]);
$compared = array_diff($day,$monthDay);
if ($compared == ""){
$age = ($today["year"]-$birthDate["2"]);
$dateArray = array( "age" => "$age", "birthday" => "True");
return print_r ($dateArray);
return True;
}
else{
if ($monthDay[0] < $day[0]){
$age = (($today["year"]-$birthDate["2"])-1);
$dateArray = array( "age" => "$age", "birthday" => "False");
return print_r($dataArray);
return True;
}
else{
$age = (($today["year"]-$birthDate["2"]));
$dateArray = array( "age" => "$age", "birthday" => "False");
return print_r($dateArray);
return True;
}
}
}
getBirthDate("9/6/1993")
?>

No comments:

Post a Comment