# Assigning DOM Object value to an array

**URL:** <https://community.unix.com/t/assigning-dom-object-value-to-an-array/367484>\
**Category:** Shell Programming and Scripting\
**Created:** [July 17, 2017, 2:24pm UTC](https://community.unix.com/t/assigning-dom-object-value-to-an-array/367484 "2017-07-17T14:24:53Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![mojoman](https://community.unix.com/letter_avatar/mojoman/32/6_449c533f586939b6e5f246632a46421f.png) [@mojoman](https://community.unix.com/u/mojoman)\
**Post date:** [July 17, 2017, 2:24pm UTC](https://community.unix.com/t/assigning-dom-object-value-to-an-array/367484/1 "2017-07-17T14:24:53Z")

</div>

Hi,

I have the following code that makes use of a URL that I store in a variable then create a document object below to work on it.

```nohighlight

    $dom = new DOMDocument;
   @$dom->loadHTML($html);

   $links = $dom->getElementsByTagName('a');

 $links = $dom->getElementsByTagName('a');

 $array = [];

    foreach ($links as $link){
    //Extract and show the "href" attribute.
    $array[]=$link->nodeValue;

} // closing bracket for the foreach

```

This does not seem to work. I need to assign the nodevalue to an array. How can I go about doing this?
