Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Backslash after single and double quotes 1

Status
Not open for further replies.

BigBadDave

Programmer
May 31, 2001
1,069
EU
Why do I get a backslash after single and double quotes using this code? :

Code:
<?php

function myReplace($string) {
    $search = array (&quot;/  /&quot;,
                     &quot;/\[b\]/&quot;,
                     &quot;/\[\/b\]/&quot;,
                     &quot;/\[u\]/&quot;,
                     &quot;/\[\/u\]/&quot;);
    $replace = array (&quot;&nbsp;&nbsp;&quot;,
                      &quot;<b>&quot;,
                      &quot;</b>&quot;,
                      &quot;<u>&quot;,
                      &quot;</u>&quot;);
    $rstring = preg_replace ($search, $replace, $string);
    return $rstring;
}

if(!@$string) {
?>
<form
  method=&quot;post&quot;
>
  <textarea name=&quot;string&quot;></textarea><br /><br />
  <input type=&quot;submit&quot; value=&quot;Go&quot;>
</form>
<?php
}
echo myReplace(nl2br(htmlentities(@$string)));
?>
Regards

Big Bad Dave

logo.gif


flashtektips@hotmail.com
 
Why do I get a backslash after single and double quotes using this code? :

<?php

function myReplace($string) {
$search = array (&quot;/ /&quot;,
&quot;/\[b\]/&quot;,
&quot;/\[\/b\]/&quot;,
&quot;/\[u\]/&quot;,
&quot;/\[\/u\]/&quot;);
$replace = array (&quot;&amp;nbsp;&amp;nbsp;&quot;,
&quot;<b>&quot;,
&quot;</b>&quot;,
&quot;<u>&quot;,
&quot;</u>&quot;);
$rstring = preg_replace ($search, $replace, $string);
return $rstring;
}

if(!@$string) {
?>
<form
method=&quot;post&quot;
>
<textarea name=&quot;string&quot;></textarea><br /><br />
<input type=&quot;submit&quot; value=&quot;Go&quot;>
</form>
<?php
}
echo myReplace(nl2br(htmlentities(@$string)));
?> Regards

Big Bad Dave

logo.gif


flashtektips@hotmail.com
 
Thanx worked great Regards

Big Bad Dave

logo.gif


davidbyng@hotmail.com
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top