PHPHtmlParser\Dom\InnerNode::previousChild PHP Method

previousChild() public method

Attempts to get the previous child.
public previousChild ( integer $id ) : AbstractNode
$id integer
return AbstractNode
    public function previousChild($id)
    {
        $child = $this->getchild($id);
        $next = $this->children[$child->id()]['prev'];
        return $this->getChild($next);
    }

Usage Example

コード例 #1
0
 /**
  * Attempts to get the previous sibling
  *
  * @return AbstractNode
  * @throws ParentNotFoundException
  */
 public function previousSibling()
 {
     if (is_null($this->parent)) {
         throw new ParentNotFoundException('Parent is not set for this node.');
     }
     return $this->parent->previousChild($this->id);
 }