You are here

function simple_html_dom_node::prev_sibling in simplehtmldom API 7

Same name and namespace in other branches
  1. 5.2 simplehtmldom/simple_html_dom.php \simple_html_dom_node::prev_sibling()
  2. 6 simplehtmldom/simple_html_dom.php \simple_html_dom_node::prev_sibling()
1 call to simple_html_dom_node::prev_sibling()
simple_html_dom_node::previousSibling in simplehtmldom/simple_html_dom.php

File

simplehtmldom/simple_html_dom.php, line 155

Class

simple_html_dom_node

Code

function prev_sibling() {
  if ($this->parent === null) {
    return null;
  }
  $idx = 0;
  $count = count($this->parent->children);
  while ($idx < $count && $this !== $this->parent->children[$idx]) {
    ++$idx;
  }
  if (--$idx < 0) {
    return null;
  }
  return $this->parent->children[$idx];
}