This code works for what I want, but I'm wondering if it's ok to do nothing inside the curly brackets of an if statement. Is there a better way to write this?
if(empty($data) || $data == "unanswered")) {
//do nothing
} else {
//display data
echo $data;
}
You could do a negation instead:
if (! empty($data) && $data != 'unanswered') {
echo $data;
}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With