fork download
  1. <?php
  2.  
  3. $answer = getBirthDate('02/01/1994');
  4. echo "Expected Answers are age 18, birthday false.\n";
  5. echo "Actual answers are age". $answer['age']. ", birthday " . $answer['birthday'];
  6.  
  7. function getBirthDate($input){
  8. $x=explode("/",$input);
  9. $i=3;
  10.  
  11. $days=8;
  12. $months=2;
  13.  
  14. $isbirthday=false;
  15. if(($days==$x[$i-2]) && ($months==$x[$i-3])){
  16. $isbirthday=true;
  17. $years=(2012-($x[$i-1]));
  18.  
  19. }
  20. elseif($months==$x[$i-3]){
  21. if($days>$x[$i-2]){
  22. $years=(2012-($x[$i-1]));
  23. }
  24. }
  25. elseif($months>$x[$i-3]){
  26. $years=(2012-($x[$i-1]));
  27. }
  28. else{
  29. $years=(2012-($x[$i-1]));
  30. }
  31. $returnarray=array('age' => $totalyears, 'birthday' => $isbirthday);
  32. return $returnarray;
  33. }
  34. ?>
Success #stdin #stdout 0.03s 13112KB
stdin
Standard input is empty
stdout
Expected Answers are age 18, birthday false.
Actual answers are age, birthday