public function dl($dt_sel = 'dt', $dd_sel = 'dd', $dw = null, $key = null)
    {
        $oneKey = isset($key);
        $dl     = $oneKey ? null : array();

        if ($dw) {
            $l = $this->find($dw);
            if ($l) {
                foreach ($l as $i => $w) {
                    if ($dt_sel) {
                        $dte = $w->find($dt_sel)->first();
                        $dt  = $dte->text();
                        if ($dd_sel) {
                            $dd = $w->find($dd_sel)->first()->text();
                        }
                        // @TODO
                        // else {
                        //     $dd = $w.contents().not($dte).text();
                        // }
                    } else {
                        if (!$dd_sel) {
                            $dd = explode(':', $w->text(), 2);
                            $dt = reset($dd);
                            $dd = end($dd);
                        }
                        // @TODO
                        // else {
                        //     $dd_ = $w->find($dd_sel)->first();
                        //     $dd = $dd_->text();
                        //     $dt = $w.contents().not($dd_).text();
                        // }
                    }
                    $dd = trim($dd);
                    $dt = trim($dt);
                    if ($oneKey) {
                        if ($key instanceof \Closure ? $key($dt, $dd) : $key == $dt) {
                            return $dd;
                        }
                    } else {
                        $dl[$dt] = $dd;
                    }
                }
            }

        } else {
            $dtl = $this->find($dt_sel);
            $ddl = $this->find($dd_sel)->toArray();
            $dd  = reset($ddl);
            foreach ($dtl as $i => $e) {
                $dt = trim($e->text());
                $dd = trim($dd->text());
                if ($oneKey) {
                    if ($key instanceof \Closure ? $key($dt, $dd) : $key == $dt) {
                        return $dd;
                    }
                } else {
                    $dl[$dt] = $dd;
                }
                $dd = next($ddl);
                if (!$dd) {
                    break;
                }

            }
        }

        return $dl;
    }
public function dl($dt_sel = 'dt', $dd_sel = 'dd', $dw = null, $key = null)
    {
        $oneKey = isset($key);
        $dl     = $oneKey ? null : array();

        if ($dw) {
            $l = $this->find($dw);
            if ($l) {
                foreach ($l as $i => $w) {
                    if ($dt_sel) {
                        $dte = $w->find($dt_sel)->first();
                        $dt  = $dte->text();
                        if ($dd_sel) {
                            $dd = $w->find($dd_sel)->first()->text();
                        }
                        // @TODO
                        // else {
                        //     $dd = $w.contents().not($dte).text();
                        // }
                    } else {
                        if (!$dd_sel) {
                            $dd = explode(':', $w->text(), 2);
                            $dt = reset($dd);
                            $dd = end($dd);
                        }
                        // @TODO
                        // else {
                        //     $dd_ = $w->find($dd_sel)->first();
                        //     $dd = $dd_->text();
                        //     $dt = $w.contents().not($dd_).text();
                        // }
                    }
                    $dd = trim($dd);
                    $dt = trim($dt);
                    if ($oneKey) {
                        if ($key instanceof \Closure ? $key($dt, $dd) : $key == $dt) {
                            return $dd;
                        }
                    } else {
                        $dl[$dt] = $dd;
                    }
                }
            }

        } else {
            $dtl = $this->find($dt_sel);
            $ddl = $this->find($dd_sel)->toArray();
            $dd  = reset($ddl);
            foreach ($dtl as $i => $e) {
                $dt = trim($e->text());
                $dd = trim($dd->text());
                if ($oneKey) {
                    if ($key instanceof \Closure ? $key($dt, $dd) : $key == $dt) {
                        return $dd;
                    }
                } else {
                    $dl[$dt] = $dd;
                }
                $dd = next($ddl);
                if (!$dd) {
                    break;
                }

            }
        }

        return $dl;
    }
public function dl ( $ dt_sel = 'dt' , $ dd_sel = 'dd' , $ dw = null , $ key = null ) { $ oneKey = isset ( $ key ) ; $ dl = $ oneKey ? null : array ( ) ; if ( $ dw ) { $ l = $ this -> find ( $ dw ) ; if ( $ l ) { foreach ( $ l as $ i => $ w ) { if ( $ dt_sel ) { $ dte = $ w -> find ( $ dt_sel ) -> first ( ) ; $ dt = $ dte -> text ( ) ; if ( $ dd_sel ) { $ dd = $ w -> find ( $ dd_sel ) -> first ( ) -> text ( ) ; } // @TODO // else { //     $dd = $w.contents().not($dte).text(); // } } else { if ( ! $ dd_sel ) { $ dd = explode ( ':' , $ w -> text ( ) , 2 ) ; $ dt = reset ( $ dd ) ; $ dd = end ( $ dd ) ; } // @TODO // else { //     $dd_ = $w->find($dd_sel)->first(); //     $dd = $dd_->text(); //     $dt = $w.contents().not($dd_).text(); // } } $ dd = trim ( $ dd ) ; $ dt = trim ( $ dt ) ; if ( $ oneKey ) { if ( $ key instanceof \ Closure ? $ key ( $ dt , $ dd ) : $ key == $ dt ) { return $ dd ; } } else { $ dl [ $ dt ] = $ dd ; } } } } else { $ dtl = $ this -> find ( $ dt_sel ) ; $ ddl = $ this -> find ( $ dd_sel ) -> toArray ( ) ; $ dd = reset ( $ ddl ) ; foreach ( $ dtl as $ i => $ e ) { $ dt = trim ( $ e -> text ( ) ) ; $ dd = trim ( $ dd -> text ( ) ) ; if ( $ oneKey ) { if ( $ key instanceof \ Closure ? $ key ( $ dt , $ dd ) : $ key == $ dt ) { return $ dd ; } } else { $ dl [ $ dt ] = $ dd ; } $ dd = next ( $ ddl ) ; if ( ! $ dd ) { break ; } } } return $ dl ; }
Definition list parser

@param  $                      $dl     dl element
@param  String|RegExp|Function $key    search for one specific key
@param  String                 $dt_sel dt selector (default "dt")
@param  String                 $dd_sel dd selector (default "dd")
@param  String                 $dw     definition term wrapper selector (default none)
@return Object|mixed           the value for $key or list of key-value if no $key
Definition list parser