In a search model I am doing
$search = Yii::$app->request->getQueryParam('PersonSearch');
Is there a simple way to know if the any of the search elements have criteria or not. Basically, I’m trying to detect if the are all empty, so none have a criteria.
Alternately, get a count of elements with a criteria
Alternately, list only the elements with a criteria
Right now I’m doing something like
$appliedSearchParams = false;
if(isset($search)){
foreach ($search as $key => $value) {
if (strlen($value)>0){
$appliedSearchParams = true;
break;
}
}
}
Is there a method I’m unaware of that would be better than the above?