phpbb\textformatter\s9e\utils::get_outermost_quote_authors PHP Method

get_outermost_quote_authors() public method

Get a list of quote authors, limited to the outermost quotes
public get_outermost_quote_authors ( string $xml ) : string[]
$xml string Parsed text
return string[] List of authors
    public function get_outermost_quote_authors($xml)
    {
        $authors = array();
        if (strpos($xml, '<QUOTE ') === false) {
            return $authors;
        }
        $dom = new \DOMDocument();
        $dom->loadXML($xml);
        $xpath = new \DOMXPath($dom);
        foreach ($xpath->query('//QUOTE[not(ancestor::QUOTE)]/@author') as $author) {
            $authors[] = $author->textContent;
        }
        return $authors;
    }