You are here

function find_contains in simplehtmldom API 7

Same name and namespace in other branches
  1. 5.2 simplehtmldom/example/simple_html_dom_utility.php \find_contains()
  2. 6 simplehtmldom/example/simple_html_dom_utility.php \find_contains()

File

simplehtmldom/example/simple_html_dom_utility.php, line 25

Code

function find_contains($html, $selector, $keyword, $index = -1) {
  $ret = array();
  foreach ($html
    ->find($selector) as $e) {
    if (strpos($e->innertext, $keyword) !== false) {
      $ret[] = $e;
    }
  }
  if ($index < 0) {
    return $ret;
  }
  return isset($ret[$index]) ? $ret[$index] : null;
}