Skip to content

Instantly share code, notes, and snippets.

@flesch
Created August 18, 2012 14:49
Show Gist options
  • Select an option

  • Save flesch/3387199 to your computer and use it in GitHub Desktop.

Select an option

Save flesch/3387199 to your computer and use it in GitHub Desktop.

Revisions

  1. flesch revised this gist Nov 22, 2012. 2 changed files with 15 additions and 15 deletions.
    15 changes: 15 additions & 0 deletions getElementsByClassName.php
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,15 @@
    <?php

    class document {
    public static function getElementsByClassName($name) {
    global $xpath;
    $nodes = array();
    $elements = $xpath->query(sprintf("//div[contains(@class, '%s')]", $name));
    foreach ($elements as $e) {
    array_push($nodes, $e);
    }
    return $nodes;
    }
    }

    ?>
    15 changes: 0 additions & 15 deletions gistfile1.php
    Original file line number Diff line number Diff line change
    @@ -1,15 +0,0 @@
    <?php
    class document {

    public static function getElementsByClassName($name) {
    global $xpath;
    $nodes = array();
    $elements = $xpath->query(sprintf("//div[contains(@class, '%s')]", $name));
    foreach($elements as $e) {
    array_push($nodes, $e);
    }
    return $nodes;
    }

    }
    ?>
  2. flesch created this gist Dec 7, 2010.
    15 changes: 15 additions & 0 deletions gistfile1.php
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,15 @@
    <?php
    class document {

    public static function getElementsByClassName($name) {
    global $xpath;
    $nodes = array();
    $elements = $xpath->query(sprintf("//div[contains(@class, '%s')]", $name));
    foreach($elements as $e) {
    array_push($nodes, $e);
    }
    return $nodes;
    }

    }
    ?>