I have a string:
$str = 'title="favorite" name="fav_1" onclick="return ..."'
I want to replace name
to class
and stripe onclick
attribute.
What I have tried ?:
$str = 'title="favorite" name="fav_12" onclick="return.."';
$replace = str_replace('name', 'class', $str);
Humm.. its okey. what is your problem ?
If I use str_replace
then I need to repeat this step two time, first for replacing name
to class
and second stripe onclick
to blank space.
Repeating code is not a problem, but str_replace
will not work If I dont know what is inside onclick="..."
.
So please suggest how do I replacing name to class and stripping onclick just in single line of code.