I accidentally experience this issue when I was writing code in one of my application.
$ar = [
   'first' => 1,
   'second' => 2,
   ......
]; 
when I tried to check that index in $array which doesn't exist
if(isset($ar['third']) && !empty($ar['third'])){
    echo "Found";
}else{
    echo "Not Found";
}
It worked without error as expected, but when I put this conditions in the common function and then checked
function sanitize($value){
   if(isset($value) && !empty($value)){
       return true;
   }else{
       return false;
   }
}
if(sanitize($ar['third'])){
   echo "Found";
}else{
   echo "Not Found";
}
Above sample throws an exception undefined index error, can someone explain why this is causing the error.