Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Added as_elements param

  • Loading branch information...
commit 0bd8ff65a024ac5bc215d496825a17cd8c11972e 1 parent 49371c0
@tj authored
Showing with 3 additions and 2 deletions.
  1. +3 −2 selector.inc
View
5 selector.inc
@@ -1,10 +1,11 @@
<?php
-function select_elements($selector, $html) {
+function select_elements($selector, $html, $as_array = true) {
$dom = new DOMDocument();
$dom->loadHTML($html);
$xpath = new DOMXpath($dom);
- return elements_to_array($xpath->evaluate(selector_to_xpath($selector)));
+ $elements = $xpath->evaluate(selector_to_xpath($selector));
+ return $as_array ? elements_to_array($elements) : $elements;
}
function elements_to_array($elements) {
Please sign in to comment.
Something went wrong with that request. Please try again.