PEAR Manual
Prev |  | Next

# Net_NNTP::selectGroup()

Net_NNTP::selectGroup() -- select a newsgroup

## Synopsis

    require_once 'Net/NNTP.php';

``array Net_NNTP::selectGroup` (string $newsgroup)`

## Description

Selects a specific newsgroup on the news server

## Parameter

- string `$newsgroup` - Name of the newsgroup to access

## Return value

`array` - If the newsgroup exists an array containing the message number of the first (array key: `['first']`) and the last message id (array key: `['last']`) or a PEAR_Error, if fail.

## Throws

Table 48-1. Possible PEAR_Error values

Error code | Error message | Reason | Solution
--- | --- | --- | ---
`NULL` | Different error messages | The messages are directly passed from the news server, in the most cases caused by calling a non existing article | Check the article ID or if your are still connected to the server ( Net_NNTP::isConnected())

## Note

This function can not be called statically.

## See

Net_NNTP::connect() , Net_NNTP::getGroups()

## Example

Example 48-1. Using selectGroup()
    ...
    $ret = $nntp->connect("news.php.net");
    if( PEAR::isError($ret)) {
     // handle error
    } else {
     // success
     $data = $nntp->selectGroup("php.pear.dev");
     // Print the count of articles
     echo "Count: ", $data['last'] - $data['first'];
    }

Prev | Home | Next
Net_NNTP::quit() | Up | Net_NNTP::setDebug()