Skip to content
Advertisement

How to pass PHP $variables in cURL array

I would like to pass some simple PHP variables (such as $name1 and $email1) to the following cURL block (PHP-Curl)

JavaScript

Basically replace:

  • percy.jackson2290@gmail.com with $email1
  • Percy Jack with $name1

Is this possible? Please help!

Advertisement

Answer

Don’t try to create JSON by hand, create an array and use json_encode()

JavaScript

For the more complex version in the comment:

JavaScript

Edited version:

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