String ersetzten

  • Huhu,


    das erreichst du mit stripslashes.


    PHP
    1. <span class="syntaxdefault"><br /><br />  $string </span><span class="syntaxkeyword">=</span><span class="syntaxdefault"> </span><span class="syntaxstring">'\"Hallo\"..\"\"'</span><span class="syntaxkeyword">;<br /><br /></span><span class="syntaxdefault">  print stripslashes</span><span class="syntaxkeyword">(</span><span class="syntaxdefault">$string</span><span class="syntaxkeyword">);<br /><br /></span><span class="syntaxdefault"> </span>


    Ausgabe: "Hallo"..""


    Dies entfernt jedoch ALLE backslashe, ansonsten so:


    PHP
    1. <span class="syntaxdefault"><br /><br /> $string </span><span class="syntaxkeyword">=</span><span class="syntaxdefault"> </span><span class="syntaxstring">'\"Hallo\"..\"\"'</span><span class="syntaxkeyword">;<br /><br /> </span><span class="syntaxdefault">$string </span><span class="syntaxkeyword">= </span><span class="syntaxdefault">preg_replace</span><span class="syntaxkeyword">(</span><span class="syntaxstring">'/\\\"/'</span><span class="syntaxkeyword">, </span><span class="syntaxstring">'"'</span><span class="syntaxkeyword">, </span><span class="syntaxdefault">$string</span><span class="syntaxkeyword">);<br /><br /> print </span><span class="syntaxdefault">$string</span><span class="syntaxkeyword">;<br /><br /> </span><span class="syntaxdefault"></span>


    Ausgabe: "Hallo".."" \