Try to search your question here, if you can't find : Ask Any Question Now ?

PHP remove/add/edit attributes

HomeCategory: stackoverflowPHP remove/add/edit attributes
Avatarsourav asked 2 weeks ago

I am using PHP and have an object called $image and this is the what the object looks like:

<img src="mypic.jpg" alt="My alternate text" width="460" title="my super title" height="259" class="blah" custom-attribute="blah" whatever-attribute="xx">

How would I 1) remove all attributes except for src, alt, title and class and
2) If the attribute class exists, replace it with class=”my own custom class” or if attribute class doesn’t exist add the class attribute class=”my own custom class”

Thanks

1 Answers
Best Answer
AvatarArben answered 2 weeks ago
Your Answer

17 + 9 =

Popular Tags

WP Facebook Auto Publish Powered By : XYZScripts.com