Permalink
Browse files

Added as_elements param

  • Loading branch information...
tj committed Jul 17, 2009
1 parent 49371c0 commit 0bd8ff65a024ac5bc215d496825a17cd8c11972e
Showing with 3 additions and 2 deletions.
  1. +3 −2 selector.inc
View
@@ -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) {

0 comments on commit 0bd8ff6

Please sign in to comment.