By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
448,798 Members | 1,388 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 448,798 IT Pros & Developers. It's quick & easy.

Replace contents of href attribute in php

P: 1
I have a php variable where the html contents are read as a string in php and I want to remove just the contents of the href and be the other intact.

$string = '<a href="javascript:#one">String</a>';
now I want to make this as given below.

<a href="">String</a>. Please note that javascript#one is not constant, It is dynamic
Feb 21 '20 #1
Share this Question
Share on Google+
1 Reply

Expert Mod 5K+
P: 5,387
you might use the preg_replace method for such a task.
Feb 21 '20 #2

Post your reply

Sign in to post your reply or Sign up for a free account.