Skip to content

Instantly share code, notes, and snippets.

@kevindees
Created May 21, 2019 15:05
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save kevindees/1cb41e52a70c82ee5bbca1bdfae94d37 to your computer and use it in GitHub Desktop.
Save kevindees/1cb41e52a70c82ee5bbca1bdfae94d37 to your computer and use it in GitHub Desktop.
Helpers when using using empty()
<?php
// do. if( empty_or($data['name'], $data['value']) )
// vs. if( !empty($data['name']) || !empty($data['value']) )
function empty_or(...$args) {
foreach ($args as $arg) {
if(empty($arg)) { return true; }
}
return false;
}
// do. if( empty_and($data['name'], $data['value']) )
// vs. if( empty($data['name']) && empty($data['value']) )
function empty_and(...$args) {
foreach ($args as $arg) {
if(!empty($arg)) { return false; }
}
return true;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment