I am trying to return an array however I keep getting the error:
Notice: Undefined variable: arr
I'm not sure where I went wrong?
<?php
$result = 1;
function getAns($result){
if($result == 1){
$arr = array("1"=>"A","2"=>"B");
}
elseif($result == 2){
$arr = array("1"=>"D","2"=>"E");
}
return $arr;
}
getAns($result);
print_r($arr);
?>