src/Imap.php
public function searchTotal(array $filter, $or = false)
    {
        Argument::i()->test(2, 'bool');

        if (!$this->socket) {
            $this->connect();
        }

        //build a search criteria
        $search = array();
        foreach ($filter as $where) {
            $item = $where[0].' "'.$where[1].'"';
            if (isset($where[2])) {
                $item .= ' "'.$where[2].'"';
            }

            $search[] = $item;
        }

        //if this is an or search
        if ($or) {
            $search = 'OR ('.implode(') (', $search).')';
        } else {
            //this is an and search
            $search = implode(' ', $search);
        }

        $response = $this->call('UID SEARCH '.$search);

        //get the result
        $result = array_pop($response);

        //if we got some results
        if (strpos($result, 'OK') !== false) {
            //parse out the uids
            $uids = explode(' ', $response[0]);
            array_shift($uids);
            array_shift($uids);

            return count($uids);
        }

        //it's not okay just return 0
        return 0;
    }
public function searchTotal(array $filter, $or = false)
    {
        Argument::i()->test(2, 'bool');

        if (!$this->socket) {
            $this->connect();
        }

        //build a search criteria
        $search = array();
        foreach ($filter as $where) {
            $item = $where[0].' "'.$where[1].'"';
            if (isset($where[2])) {
                $item .= ' "'.$where[2].'"';
            }

            $search[] = $item;
        }

        //if this is an or search
        if ($or) {
            $search = 'OR ('.implode(') (', $search).')';
        } else {
            //this is an and search
            $search = implode(' ', $search);
        }

        $response = $this->call('UID SEARCH '.$search);

        //get the result
        $result = array_pop($response);

        //if we got some results
        if (strpos($result, 'OK') !== false) {
            //parse out the uids
            $uids = explode(' ', $response[0]);
            array_shift($uids);
            array_shift($uids);

            return count($uids);
        }

        //it's not okay just return 0
        return 0;
    }
public function searchTotal ( array $ filter , $ or = false ) { Argument :: i ( ) -> test ( 2 , 'bool' ) ; if ( ! $ this -> socket ) { $ this -> connect ( ) ; } //build a search criteria $ search = array ( ) ; foreach ( $ filter as $ where ) { $ item = $ where [ 0 ] . ' "' . $ where [ 1 ] . '"' ; if ( isset ( $ where [ 2 ] ) ) { $ item .= ' "' . $ where [ 2 ] . '"' ; } $ search [ ] = $ item ; } //if this is an or search if ( $ or ) { $ search = 'OR (' . implode ( ') (' , $ search ) . ')' ; } else { //this is an and search $ search = implode ( ' ' , $ search ) ; } $ response = $ this -> call ( 'UID SEARCH ' . $ search ) ; //get the result $ result = array_pop ( $ response ) ; //if we got some results if ( strpos ( $ result , 'OK' ) !== false ) { //parse out the uids $ uids = explode ( ' ' , $ response [ 0 ] ) ; array_shift ( $ uids ) ; array_shift ( $ uids ) ; return count ( $ uids ) ; } //it's not okay just return 0 return 0 ; }
Returns the total amount of emails

@param *array $filter Search filters
@param bool   $or     Is this an OR search ?

@return number
Returns the total amount of emails