Skip to content
Advertisement

Sending array having space in keys being removed when sending by cURL

I have a strange issue.

JavaScript

I am sending this data using cURL …

JavaScript

On receiveing end, I am just printing it back.

echo print_r($_POST);

Which prints it out as

JavaScript

It’s removing array keys with spacing.

Any ideas, what could be causing it?

Advertisement

Answer

Your spaces in params are replaced with + when you use http_build_query(), try providing an array without this function when you set the CURLOPT_POSTFIELDS option.

You can read about it in docs… https://www.php.net/manual/ru/function.http-build-query.php#95784

User contributions licensed under: CC BY-SA
2 People found this is helpful
Advertisement