public static function text_parse_dl($dl, $sep = ':', $key = null)
    {
        // Get the textContents of $dl
        if ($dl instanceof self) {
            if (count($dl) > 1) {
                $ln = array();
                foreach ($dl as $o) {
                    $ln[] = $o->text();
                }

                $dl = implode("\n", $ln);
            } else {
                $dl = $dl->text();
            }
        }

        $dl = trim($dl);

        $oneKey = isset($key);
        $o      = $oneKey ? false : array();
        if (!$dl) {
            return $o;
        }

        $ln = explode("\n", $dl);
        if (!count($ln)) {
            return $o;
        }

        foreach ($ln as $i => $l) {
            $l = trim($l);
            if (!$l) {
                continue;
            }

            $l = explode($sep, $l, 2);
            $i = rtrim(reset($l));
            $l = ltrim(end($l));
            if ($oneKey) {
                if ($key instanceof \Closure ? $key($i, $l) : $key == $i) {
                    return $l;
                }
            } else {
                $o[$i] = $l;
            }
        }

        return $o;
    }
public static function text_parse_dl($dl, $sep = ':', $key = null)
    {
        // Get the textContents of $dl
        if ($dl instanceof self) {
            if (count($dl) > 1) {
                $ln = array();
                foreach ($dl as $o) {
                    $ln[] = $o->text();
                }

                $dl = implode("\n", $ln);
            } else {
                $dl = $dl->text();
            }
        }

        $dl = trim($dl);

        $oneKey = isset($key);
        $o      = $oneKey ? false : array();
        if (!$dl) {
            return $o;
        }

        $ln = explode("\n", $dl);
        if (!count($ln)) {
            return $o;
        }

        foreach ($ln as $i => $l) {
            $l = trim($l);
            if (!$l) {
                continue;
            }

            $l = explode($sep, $l, 2);
            $i = rtrim(reset($l));
            $l = ltrim(end($l));
            if ($oneKey) {
                if ($key instanceof \Closure ? $key($i, $l) : $key == $i) {
                    return $l;
                }
            } else {
                $o[$i] = $l;
            }
        }

        return $o;
    }
public static function text_parse_dl ( $ dl , $ sep = ':' , $ key = null ) { // Get the textContents of $dl if ( $ dl instanceof self ) { if ( count ( $ dl ) > 1 ) { $ ln = array ( ) ; foreach ( $ dl as $ o ) { $ ln [ ] = $ o -> text ( ) ; } $ dl = implode ( "\n" , $ ln ) ; } else { $ dl = $ dl -> text ( ) ; } } $ dl = trim ( $ dl ) ; $ oneKey = isset ( $ key ) ; $ o = $ oneKey ? false : array ( ) ; if ( ! $ dl ) { return $ o ; } $ ln = explode ( "\n" , $ dl ) ; if ( ! count ( $ ln ) ) { return $ o ; } foreach ( $ ln as $ i => $ l ) { $ l = trim ( $ l ) ; if ( ! $ l ) { continue ; } $ l = explode ( $ sep , $ l , 2 ) ; $ i = rtrim ( reset ( $ l ) ) ; $ l = ltrim ( end ( $ l ) ) ; if ( $ oneKey ) { if ( $ key instanceof \ Closure ? $ key ( $ i , $ l ) : $ key == $ i ) { return $ l ; } } else { $ o [ $ i ] = $ l ; } } return $ o ; }
Textual definition list parser

@param  $|string       $dl  text or Element containing definition list text
@param  string         $sep key-value separator (default ":")
@param  string|Closure $key search for one specific key
@return array|mixed    the value for $key or list of key-value if no $key
Textual definition list parser