original_string: public function searchGroups($search, $by, $limit = 1, $num = 1000, $page = 1)
      {
          $groups = $this->indexGroups($num, $page)['data'];
  
          $filtered = array_filter(
              $groups,
              function ($group) use ($search, $by) {
  
                  if (array_key_exists($by, $group)) {
                      if (strpos($group[$by], $search) !== false) {
                          return $group;
                      }
                      if ($group[$by] === $search) {
                          return $group;
                      }
                  }
  
                  return false;
              }
          );
  
          if ($limit == 1) {
              return array_shift($filtered);
          }
  
          return array_slice($filtered, 0, $limit);
      }
code: public function searchGroups($search, $by, $limit = 1, $num = 1000, $page = 1)
      {
          $groups = $this->indexGroups($num, $page)['data'];
  
          $filtered = array_filter(
              $groups,
              function ($group) use ($search, $by) {
  
                  if (array_key_exists($by, $group)) {
                      if (strpos($group[$by], $search) !== false) {
                          return $group;
                      }
                      if ($group[$by] === $search) {
                          return $group;
                      }
                  }
  
                  return false;
              }
          );
  
          if ($limit == 1) {
              return array_shift($filtered);
          }
  
          return array_slice($filtered, 0, $limit);
      }
code_tokens: public function searchGroups ( $ search , $ by , $ limit = 1 , $ num = 1000 , $ page = 1 ) { $ groups = $ this -> indexGroups ( $ num , $ page ) [ 'data' ] ; $ filtered = array_filter ( $ groups , function ( $ group ) use ( $ search , $ by ) { if ( array_key_exists ( $ by , $ group ) ) { if ( strpos ( $ group [ $ by ] , $ search ) !== false ) { return $ group ; } if ( $ group [ $ by ] === $ search ) { return $ group ; } } return false ; } ) ; if ( $ limit == 1 ) { return array_shift ( $ filtered ) ; } return array_slice ( $ filtered , 0 , $ limit ) ; }
docstring: Search if a defined number of Groups exists.
  
  @param string $search
  @param string $by
  @param int    $num
  @param int    $page
  @param int    $limit
  
  @return mixed
docstring_tokens: Search if a defined number of Groups exists .