How to edit a php/html file using PHP

I'm trying to design an interface to change <img> sources throughout my website, so that I don't need to change the sources by hand anytime we want to change what images my site displays.

I looked at DOMDocument already, and while it's useful for accessing the different elements in a file, it wraps the files in it's own HTML tags, which messes up the files (I already tried looking here but those solutions didn't work for me)

Is there a better way to take a file, retrieve element information and attributes (like src and id) from img tags, edit those elements, and save the file?


Just to close this up - I ended up using Querypath to accomplish this task. It works pretty well and was pretty simple to utilize.

Need Your Help

Side menu runs but routes file shows nothing

javascript angularjs meteor ionic-framework sidebar

I am trying to make a simple side menu with chats events and settings tab. It runs if i remove the settings and events block from the routes js file but shows nothing.

Cannot unbind and close events in my Backbone router

javascript backbone.js

I want to clean up my views in Backbone, before loading new views.