Question: `$image` variable gives this code (when `echo` is used):

```
<img src="/image.png" width="100" height="147" alt="" class="some_class" />

```

* `width`, `height`, `src` and `class` 
attributes can be different.

What should we do:

1. **remove** `width` and `height` from `$image`
2. replace `alt=""` with `alt="Poster"`

Thanks.

Answer: 
If the attributes can be variable, then your best choice for working with the HTML is to use a library that actually understands HTML, like [DOM](http://de3.php.net/manual/en/book.dom.php). 

```
$dom = new DOMDocument;
$dom->loadXML($variable);
$dom->documentElement->removeAttribute('width');
$dom->documentElement->removeAttribute('height');
$dom->documentElement->setAttribute('alt', 'poster');
echo $dom->saveXML($dom->documentElement);

```

outputs:

```
<img src="http://site.com/image.png" alt="poster"/>

```
will also replace `<embed width="x">` which is wrong. We need to catch only with `<img>` tag