0

サーバーで作業していると思いますが、magic_quotes がアクティブで、jquery.ajax から json を受け取ると、次のようにします。

alcancesP = stripslashes($_POST['alcances']);

alcancesP をデコードした後:

$dataAlcances = json_decode(alcancesP,true);

しかし、$dataAlcancesを foreach に渡すと、'\' は消えますが、T と N は消えません。

アルカンセスポストです

alcances    [{"marca":"4","marcatxt":"\n\t\tCitrix\t\t\t","producto":"2","productotxt":"Networking","subproducto":"2","subproductotxt":"Netscaler"},{"marca":"8","marcatxt":"\n\t\tCoca Cola Company\t\t\t","producto":"8","productotxt":"Del Valle","subproducto":"5","subproductotxt":"Valle Frut"}]

このデータをテーブルに保存するときは、次のように挿入します。

nttCitrixttt             |     Networking     |    Netscaler
nttCoca Cola Companyttt  |    Del Valle       |    Valle Frut

N と T を削除して正しく保存したい。

残念ながら、サーバーにアクセスして php.ini を変更し、マジック クォートを無効にすることはできません。

私を助けてくれることを願っています。前もって感謝します。

4

1 に答える 1

0

str_replaceを使用する

$str = str_replace(array('\t','\n'),'',$str);

またはpreg_replace

$str = preg_replace('/(\\\\n|\\\\t)/', '', $str);
于 2013-02-06T18:07:21.817 に答える