Basically, I have a string with HTML, and I'm trying to alter it with str_replace before serving it to the browser...
$content = str_replace("accesskey=\"x\"", "accesskey=\"x\" value=\"Preview\"', $content) ;
Okay, so I want to find the HTML tag that has the accesskey="x" tag and append a value tag to it. However, try as I might, the str_replace seems to do nothing.
HOWEVER if I do this:
$content = str_replace("accesskey=\"x\"", "a", $content) ;
it ends up with:
a=""
???
This is really baffling me, I've tried all the str_replace variants, I've tried using 'accesskey="x"', I've tried:
$content = str_replace("accesskey", "value=\"Preview\" accesskey", $content) ;
I've tried:
$content = str_replace("accesskey", "value=\'Preview\' accesskey", $content) ;
It just seems that if an =, ", ', ;, : or any other symbol is in either of the strings it fails to do anything... I've looked at the string in a debugger and it does indeed have the escape characters: \" but I've tried it without regardless.
I can't use htmlspecialchars etc because I need it to be parsed as html when it's echoed to the screen.
Please help :-S I've been hacking away at this for literally 10 hours+ and can only imagine I'm doing something ridiculously thick for seemingly no one on the entire internet has had the same problem if my 1000s of google searches are anything to go by
Sorry for the ranty post, and any help would be much appreciated!
Thanks,
lemmy