Function that determine if value is empty and return NA if not return the value?
0
0
Entering edit mode
6.0 years ago
nemo ▴ 40

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 • 871 views
ADD COMMENT
0
Entering edit mode

Why don't you define the function?

ADD REPLY

Login before adding your answer.

Traffic: 2308 users visited in the last hour
Help About
FAQ
Access RSS
API
Stats

Use of this site constitutes acceptance of our User Agreement and Privacy Policy.

Powered by the version 2.3.6