vendredi 1 avril 2016

Optimize PHP If Statement Logic

I would like to optimize this:

if (isset($value->videoURL) && empty($value->videoURL)) {
  unset($value->videoURL);
}
if (isset($value->videoID) && empty($value->videoID)) {
  unset($value->videoID);
}

In a single PHP if logic

if ((isset($value->videoID) && empty($value->videoID)) || isset($value->writer) && empty($value->writer)) {
  unset($value->videoID);
  unset($value->writer);
}

I know this is totally incorrect, hence I'm looking for some suggestions.

Aucun commentaire:

Enregistrer un commentaire