Skip to content
Advertisement

send post json with php (curl)

i done search tutorial for send post json with curl .. but for this value i cant find in here.. and my question how to convert to array post json in value if like this, and this my value post json

JavaScript

i done try to php array like this but still error

JavaScript

maybe someone can help me.. and sory for my bad english

thanks

Advertisement

Answer

There is the following error – the phone number has to be string, not number, so it would look like this 'phone' => '08123456789', because numbers cannot begin with 0.

Beside this, there is the following issue – You should not set item_details like this, but rather 'item_details' => [$item]. You do not need 2 nested arrays, just one. (array() is equal to []. They are practically the same in your use case. So you are doing something like array(array($item)), which is wrong)

What else, you have to do a $json = json_encode($data2); at the end and it will return what you want it to.

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