$element
contains an image, like: <img src='example.com/img.png'>
. Is there anyway I can add the title $descr
on $element
instead of the current anchor wrapping it?
echo "<a class='target-link' target='_blank' title='$descr' href='$url'>$element</a>";
Try this I hope this is the same you are looking for
$desrc = "This is normal text";
$element = "<img src='https://www.example.com' alt='$desrc' />";
echo "<a href='#' title='$desrc'>".$element."</a>";
Or you can try by using it like this
$desrc = "This is normal text";
$element = "<img src='https://www.example.com' alt='' />";
echo "<a href='#' target='_blank' title='$desrc'>".str_replace("alt='game img'", "title='".$desrc."'", $element)."</a>";