<?php
// Load up the HTML in DOMDocument
$doc = new DOMDocument;
$doc->loadHTML( '<a class="modal">Stuff</a>'); // Or: $doc->loadHTML( $this->form->getInput('image_intro', 'images'));
// Create a new XPath object to find the correct <a> tags
$xpath = new DOMXPath( $doc);
// Iterate over all <a class="modal"> tags
foreach( $xpath->query( "//a[@class='modal']") as $a) {
// Set the class attribute correctly
$a->setAttribute( 'class', $a->getAttribute( 'class') . '-link');
echo $doc->saveHTML( $a); // Print the fixed <a> tag
}