Skip to content
Advertisement

Need to pass dynamic values inside CURLOPT_POSTFIELDS

I have to make a post request and have done the same using postman for testing. Now, the code base is using php and I have never used php ever before. Upon checking the code section in postman, I got this:

JavaScript

The problem is that I have to pass dynamic values instead of firstname, lastname4 etc. The values I have are stored as such $lead['name'].

So, basically I have to pass $lead['name'] instead of lastname4 but I am not able to figure out the syntax.

Advertisement

Answer

You can use json_encode on an array to build the desired JSON string

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