Skip to content

Instantly share code, notes, and snippets.

@itswadesh
Created March 27, 2017 16:22
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 itswadesh/752d5e8c3ab00b5f5c56554640a9e7a0 to your computer and use it in GitHub Desktop.
Save itswadesh/752d5e8c3ab00b5f5c56554640a9e7a0 to your computer and use it in GitHub Desktop.
function verifyRequiredParams($inArray, $requiredColumns) {
$error = false;
$errorColumns = "";
foreach ($requiredColumns as $field) {
if (!isset($inArray[$field]) || strlen(trim($inArray[$field])) <= 0) {
$error = true;
$errorColumns .= $field . ', ';
}
}
if ($error) {
$response = array();
$response["status"] = "error";
$response["message"] = 'Required field(s) ' . rtrim($errorColumns, ', ') . ' is missing or empty';
print_r($response);
exit;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment