original_string: public static function getExcerptFromHtml($html, $tag)
      {
          $doc = new \DOMDocument();
          $doc->loadHTML($html);
          $images = $doc->getElementsByTagName($tag);
          $excerpt = null;
  
          foreach ($images as $image) {
              $attributes = [];
              foreach ($image->attributes as $name => $value) {
                  $attributes[$name] = $value->value;
              }
              $excerpt = [
                  'element' => [
                      'name'       => $image->tagName,
                      'attributes' => $attributes
                  ]
              ];
          }
  
          return $excerpt;
      }
code: public static function getExcerptFromHtml($html, $tag)
      {
          $doc = new \DOMDocument();
          $doc->loadHTML($html);
          $images = $doc->getElementsByTagName($tag);
          $excerpt = null;
  
          foreach ($images as $image) {
              $attributes = [];
              foreach ($image->attributes as $name => $value) {
                  $attributes[$name] = $value->value;
              }
              $excerpt = [
                  'element' => [
                      'name'       => $image->tagName,
                      'attributes' => $attributes
                  ]
              ];
          }
  
          return $excerpt;
      }
code_tokens: public static function getExcerptFromHtml ( $ html , $ tag ) { $ doc = new \ DOMDocument ( ) ; $ doc -> loadHTML ( $ html ) ; $ images = $ doc -> getElementsByTagName ( $ tag ) ; $ excerpt = null ; foreach ( $ images as $ image ) { $ attributes = [ ] ; foreach ( $ image -> attributes as $ name => $ value ) { $ attributes [ $ name ] = $ value -> value ; } $ excerpt = [ 'element' => [ 'name' => $ image -> tagName , 'attributes' => $ attributes ] ] ; } return $ excerpt ; }
docstring: Get an Excerpt array from a chunk of HTML
  
  @param string $html         Chunk of HTML
  @param string $tag          A tag, for example `img`
  @return array|null   returns nested array excerpt
docstring_tokens: Get an Excerpt array from a chunk of HTML