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);
    }
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);
    }
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 ) ; }
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
Search if a defined number of Groups exists .