Petsmacker Posted April 4, 2009 Share Posted April 4, 2009 <? $p=$_POST['p']; if ($_POST['p']){ $p=str_replace("“", "\"", $p); $p=str_replace("”", "\"", $p); $p=str_replace("’", "'", $p); $p=str_replace("‘", "'", $p); $p=str_replace("–", "-", $p); $p=str_replace("•", "-", $p); }?> <table width="100%"><tr><td class="left"><div id="gg"><?echo "$p";?></div></td></tr></table><br><br> <form method="POST" name="ff"> <textarea style="width:60%;height:400px;" name="p"></textarea> <br><input type="submit" value="Go"> </form> My code is as simple as that but str_replace isn't changing them. Thats ALL the HTML and PHP on my page I've stripped away any other things that could cause it. Thats all on my page. Why aren't things changing? Link to comment Share on other sites More sharing options...
Zane Posted April 4, 2009 Share Posted April 4, 2009 because if ($_POST['p']) isn't ever true. it should be if (isset($_POST['p']) && !empty($_POST['p'])) but actually you should call that FIRST if (isset($_POST['p']) && !empty($_POST['p'])){ $p=$_POST['p']; $p=str_replace("“", "\"", $p); $p=str_replace("”", "\"", $p); $p=str_replace("’", "'", $p); $p=str_replace("‘", "'", $p); $p=str_replace("–", "-", $p); $p=str_replace("•", "-", $p); }?> Link to comment Share on other sites More sharing options...
Petsmacker Posted April 4, 2009 Author Share Posted April 4, 2009 If I add: $p=str_replace("a", "gfdgfgfdg", $p); to it it works just fine. Nonetheless, I tried adding your bit but no, it does nothing. The characters aren't replaced. Letters, numbers and simple punctuation don't seem to be a problem for str_replace to work but I can't get it to with those characters. Link to comment Share on other sites More sharing options...
kenrbnsn Posted April 4, 2009 Share Posted April 4, 2009 What you are trying to do is replace "smart quotes" (dumb Microsoft quotes). Please read Convert Smart Quotes with PHP. Ken Link to comment Share on other sites More sharing options...
Petsmacker Posted April 4, 2009 Author Share Posted April 4, 2009 Legend. Thats solved the issue. Needless complications... Link to comment Share on other sites More sharing options...
Recommended Posts