parent(); $link_node->remove(); $img = $doc->createElement('img'); $img->setAttribute('src', $local_href); $img->setAttribute('alt', $href); $parent->appendChild($doc->createElement('br')); $parent->appendChild($img); }); } catch (Exception $e) { fatalError($e->getMessage()); } file_put_contents($file, iconv('utf-8', 'windows-1251//IGNORE', $doc->outertext));