php - replace href from DOMDocument from new href -


i looking change src of

$doc = new domdocument(); $doc->loadhtml($img_tag); $tags = $doc->getelementsbytagname('link'); foreach ($tags $tag) {     $old_src = $tag->getattribute('href');     $new_src_url = $sintax; //'website.com/assets/'.$old_src;     $new_src_url = str_replace ( "to_freplacer" , $old_src , $new_src_url );     if ($old_src) {         //  echo $old_src . "<br>";     }     $tag->setattribute('href', $new_src_url); } return $doc->savehtml(); 

what doing wrong? thanks


Comments

Popular posts from this blog

ubuntu - PHP script to find files of certain extensions in a directory, returns populated array when run in browser, but empty array when run from terminal -

php - How can i create a user dashboard -

javascript - How to detect toggling of the fullscreen-toolbar in jQuery Mobile? -