Reputation: 161
I'm sending an array with data over cURL to another server (with PHP). Code before sending:
$array = array('title' => "M&M's milk chocolate");
$data = json_encode($array);
and code on the other side
$data = json_decode($_POST);
If there is and (&) sign in array, the $data on other side is empty.
How can I fix it? Thanks!
Upvotes: 0
Views: 71
Reputation: 6058
Html encoding the data should work for you.
$array = array('title' => urlencode("M&M's milk chocolate"));
$data = json_encode($array);
And on the receiving end:
$data = json_decode($_POST);
$title = urldecode($data['title']);
Upvotes: 2