protected function _validateAddress($address)
    {
        $is_group = false;
        $addresses = array();

        if ($address['group']) {
            $is_group = true;

            // Get the group part of the name
            $parts     = explode(':', $address['address']);
            $groupname = $this->_splitCheck($parts, ':');
            $structure = array();

            // And validate the group part of the name.
            if (!$this->_validatePhrase($groupname)){
                $this->error = 'Group name did not validate.';
                return false;
            } else {
                // Don't include groups if we are not nesting
                // them. This avoids returning invalid addresses.
                if ($this->nestGroups) {
                    $structure = new stdClass;
                    $structure->groupname = $groupname;
                }
            }

            $address['address'] = ltrim(substr($address['address'], strlen($groupname . ':')));
        }

        // If a group then split on comma and put into an array.
        // Otherwise, Just put the whole address in an array.
        if ($is_group) {
            while (strlen($address['address']) > 0) {
                $parts       = explode(',', $address['address']);
                $addresses[] = $this->_splitCheck($parts, ',');
                $address['address'] = trim(substr($address['address'], strlen(end($addresses) . ',')));
            }
        } else {
            $addresses[] = $address['address'];
        }

        // Trim the whitespace from all of the address strings.
        array_map('trim', $addresses);

        // Validate each mailbox.
        // Format could be one of: name <geezer@domain.com>
        //                         geezer@domain.com
        //                         geezer
        // ... or any other format valid by RFC 822.
        for ($i = 0; $i < count($addresses); $i++) {
            if (!$this->validateMailbox($addresses[$i])) {
                if (empty($this->error)) {
                    $this->error = 'Validation failed for: ' . $addresses[$i];
                }
                return false;
            }
        }

        // Nested format
        if ($this->nestGroups) {
            if ($is_group) {
                $structure->addresses = $addresses;
            } else {
                $structure = $addresses[0];
            }

        // Flat format
        } else {
            if ($is_group) {
                $structure = array_merge($structure, $addresses);
            } else {
                $structure = $addresses;
            }
        }

        return $structure;
    }
protected function _validateAddress($address)
    {
        $is_group = false;
        $addresses = array();

        if ($address['group']) {
            $is_group = true;

            // Get the group part of the name
            $parts     = explode(':', $address['address']);
            $groupname = $this->_splitCheck($parts, ':');
            $structure = array();

            // And validate the group part of the name.
            if (!$this->_validatePhrase($groupname)){
                $this->error = 'Group name did not validate.';
                return false;
            } else {
                // Don't include groups if we are not nesting
                // them. This avoids returning invalid addresses.
                if ($this->nestGroups) {
                    $structure = new stdClass;
                    $structure->groupname = $groupname;
                }
            }

            $address['address'] = ltrim(substr($address['address'], strlen($groupname . ':')));
        }

        // If a group then split on comma and put into an array.
        // Otherwise, Just put the whole address in an array.
        if ($is_group) {
            while (strlen($address['address']) > 0) {
                $parts       = explode(',', $address['address']);
                $addresses[] = $this->_splitCheck($parts, ',');
                $address['address'] = trim(substr($address['address'], strlen(end($addresses) . ',')));
            }
        } else {
            $addresses[] = $address['address'];
        }

        // Trim the whitespace from all of the address strings.
        array_map('trim', $addresses);

        // Validate each mailbox.
        // Format could be one of: name <geezer@domain.com>
        //                         geezer@domain.com
        //                         geezer
        // ... or any other format valid by RFC 822.
        for ($i = 0; $i < count($addresses); $i++) {
            if (!$this->validateMailbox($addresses[$i])) {
                if (empty($this->error)) {
                    $this->error = 'Validation failed for: ' . $addresses[$i];
                }
                return false;
            }
        }

        // Nested format
        if ($this->nestGroups) {
            if ($is_group) {
                $structure->addresses = $addresses;
            } else {
                $structure = $addresses[0];
            }

        // Flat format
        } else {
            if ($is_group) {
                $structure = array_merge($structure, $addresses);
            } else {
                $structure = $addresses;
            }
        }

        return $structure;
    }
protected function _validateAddress ( $ address ) { $ is_group = false ; $ addresses = array ( ) ; if ( $ address [ 'group' ] ) { $ is_group = true ; // Get the group part of the name $ parts = explode ( ':' , $ address [ 'address' ] ) ; $ groupname = $ this -> _splitCheck ( $ parts , ':' ) ; $ structure = array ( ) ; // And validate the group part of the name. if ( ! $ this -> _validatePhrase ( $ groupname ) ) { $ this -> error = 'Group name did not validate.' ; return false ; } else { // Don't include groups if we are not nesting // them. This avoids returning invalid addresses. if ( $ this -> nestGroups ) { $ structure = new stdClass ; $ structure -> groupname = $ groupname ; } } $ address [ 'address' ] = ltrim ( substr ( $ address [ 'address' ] , strlen ( $ groupname . ':' ) ) ) ; } // If a group then split on comma and put into an array. // Otherwise, Just put the whole address in an array. if ( $ is_group ) { while ( strlen ( $ address [ 'address' ] ) > 0 ) { $ parts = explode ( ',' , $ address [ 'address' ] ) ; $ addresses [ ] = $ this -> _splitCheck ( $ parts , ',' ) ; $ address [ 'address' ] = trim ( substr ( $ address [ 'address' ] , strlen ( end ( $ addresses ) . ',' ) ) ) ; } } else { $ addresses [ ] = $ address [ 'address' ] ; } // Trim the whitespace from all of the address strings. array_map ( 'trim' , $ addresses ) ; // Validate each mailbox. // Format could be one of: name <geezer@domain.com> //                         geezer@domain.com //                         geezer // ... or any other format valid by RFC 822. for ( $ i = 0 ; $ i < count ( $ addresses ) ; $ i ++ ) { if ( ! $ this -> validateMailbox ( $ addresses [ $ i ] ) ) { if ( empty ( $ this -> error ) ) { $ this -> error = 'Validation failed for: ' . $ addresses [ $ i ] ; } return false ; } } // Nested format if ( $ this -> nestGroups ) { if ( $ is_group ) { $ structure -> addresses = $ addresses ; } else { $ structure = $ addresses [ 0 ] ; } // Flat format } else { if ( $ is_group ) { $ structure = array_merge ( $ structure , $ addresses ) ; } else { $ structure = $ addresses ; } } return $ structure ; }
Function to begin checking the address.

@param string $address The address to validate.
@return mixed False on failure, or a structured array of address information on success.
Function to begin checking the address .