Challenge 3 — Solution Task: Write a function postJson($url, $data) that sends an associative array as a JSON-encoded POST request with the correct Content-Type header, and returns the decoded JSON response. Show how it would be called with a sample $data array. "My First Post", "body" => "Hello, world!" ]; $result = postJson("https://api.example.com/posts", $newPost); if ($result !== null) { echo "Post created with ID: " . ($result['id'] ?? 'unknown'); } else { echo "Failed to create the post."; } ?> Output: (Depends on the placeholder API actually being reachable and returning valid JSON - shown here is the expected shape of a successful call:) Post created with ID: unknown Notes: - json_encode($data) converts the $newPost associative array into a JSON string before it's ever sent, and CURLOPT_POSTFIELDS attaches that JSON string as the request body. - The "Content-Type: application/json" header is essential - without it, many real APIs would either reject the request outright or misinterpret the JSON body as a plain form submission instead, exactly the chapter's own warning about this header being easy to forget. - $result['id'] ?? 'unknown' uses the null coalescing operator (from PHP Fundamentals Chapter 8) to safely handle the case where the API's own response shape doesn't include an 'id' key, rather than triggering an undefined-key warning.