[thelist] PHP - str_replace problem
Hassan Schroeder
hassan at webtuitive.com
Wed Oct 20 01:20:44 CDT 2004
Chris Ditty wrote:
> Hi all. I'm trying to do a little code snippets page for a site I am
> working on. I figured it would be simple enough. I would do a
> str_replace and replace the various html codes with the ascii
> eqivulant.
> $snippetCode = str_replace("\n", "<br>", $snippet['snippetCode']);
> $snippetCode = str_replace("<", ">", $snippetCode);
> $snippetCode = str_replace(">", "<", $snippetCode);
> $snippetCode = str_replace("&", "&", $snippetCode);
>
> This is what is in $snippet['snippetCode'].
> ?><pre><? print_r($ArrayName); ?></pre><?
>
> This is what is showing on the web page.
> ?<>pre<>? print_r($ArrayName); ?<>/pre<>?
Uh, isn't that what you've told it to create? :-)
'<' gets turned into '<' which is then turned into '&lt;' *
Might want to consider the order of those replacement statements!
(*Note: < is actually lt and > is gt)
HTH,
--
Hassan Schroeder ----------------------------- hassan at webtuitive.com
Webtuitive Design === (+1) 408-938-0567 === http://webtuitive.com
dream. code.
More information about the thelist
mailing list