This is a test version of Biostars. For the public version, visit https://www.biostars.org.
Function that determine if value is empty and return NA if not return the value?

I am looking for a function that could directly determine if the value is missing or not. I could use this code:

$data = array();
if (empty($row['AccessionNumber'])) {
    $data[] = 'NA';
    #echo "NA";
}  
else {
     $data[] = $row['AccessionNumber'];
     #echo $row['AccessionNumber'];
   }

but it is too extensive. Because I want to use the code on multiple row and in different parts of my script. I think it would be easier if I just could use a function that does it instantly. I try to use this code:

isset($row['AccesionNumber'])?$row['AccesionNumber']:'NA'

But it always return NA and not the value if there is one.

php function na

Why don't you define the function?

0 answers

No answers yet.

Log in to answer this question.