Menu

#204 Convenience function for getting first element

open
nobody
None
2025-11-06
2022-12-07
No

diff --git a/HtmlNode.php b/HtmlNode.php
index 9649d37..1f47a4a 100644
--- a/HtmlNode.php
+++ b/HtmlNode.php
@@ -550 +550,10 @@ class HtmlNode

  • function first($selector, $idx = 0, $lowercase = false)
  • {
  • return $this->expect($selector, $idx, $lowercase)

95% of element lookups not for a list of elements are for the first element, so a convenience function seems warranted, so you don't have to add ", 0" constantly.

Discussion

  • Anonymous

    Anonymous - 2022-12-07
    diff --git a/HtmlNode.php b/HtmlNode.php
    index 9649d37..aef8b17 100644
    --- a/HtmlNode.php
    +++ b/HtmlNode.php
    @@ -549,3 +549,12 @@ class HtmlNode
    
    +       function first($selector, $idx = 0, $lowercase = false)
    +       {
    +               return $this->expect($selector, $idx, $lowercase);
    +       }
    

    Missed semicolon and preformatting.

     
  • Anonymous

    Anonymous - 2025-11-06

    DELETE THIS BUG REPORT

     

Log in to post a comment.

MongoDB Logo MongoDB