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!
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']);
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.