Issue
I am facing some issue with json_encode.
when i json_encode an array having new lines it is not escaping new lines instead it's removing \ and keeping n.
ex: $array = array('name'=> "some text \n\r text");
$results = json_encode($array);
it is saving some text nr text
in database .
i am using php 5.3.8
.
edit:
This is my original code i am using
$attr = array();
for($i=0; $i < count($_POST['key']); $i++){
$attr[$_POST['key'][$i]] = $_POST['value'][$i];
}
echo json_encode(array('custom' => $attr));
these POST
values getting from form.
Solution
I figured out this issue. it is not in json_encode problem. it is an error while saving to database.
The problem is magic_quotes_gpc enabled in server. in my application if magic_quotes enabled i am striping the slashes.
i disabled magic_quotes_gpc. working fine now.
Thanks for every body.
Answered By - sankar.suda
0 Comments:
Post a Comment
Note: Only a member of this blog may post a comment.