Source Code:
(back to article)
<?php $url = 'https://jsonplaceholder.typicode.com/posts'; $data = ['key1' => 'value1', 'key2' => 'value2']; $curl = curl_init($url); curl_setopt($curl, CURLOPT_POST, true); curl_setopt($curl, CURLOPT_POSTFIELDS, http_build_query($data)); curl_setopt($curl, CURLOPT_RETURNTRANSFER, true); $result = curl_exec($curl); curl_close($curl); var_dump(json_decode($result, true));
Result:
Report an issue