With your current syntax, what do you expect your function to return when $data[0]
is not set? Surely you don't expect your function to not return anything, depending upon a condition.
The only alternative I see is the ternary operator, where you return something other than $data[0]
when it is not set:
return isset($data[0]) ? $data[0] : null;