How do I pick the Header Location and Discard the rest after POST request in PHP?

Am doing a POST request in PHP and it returns header. Am using the code below.

<?php
$curl = curl_init();
curl_setopt_array($curl, array(
CURLOPT_URL => 'https://sandbox.kopokopo.com/api/v1/payments',
CURLOPT_RETURNTRANSFER => true,
CURLOPT_HEADER => 1,
CURLOPT_ENCODING => '',
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 0,
CURLOPT_FOLLOWLOCATION => true,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => 'POST',
CURLOPT_POSTFIELDS =>'{
  "destination_type": "till",
  "destination_reference": "3eccf0c1-ab6b-41a4-b51a-4e8f588105f1",
  "description": "4563",
  "amount": {
      "currency": "KES",
      "value": "500"
  },
   "metadata": {
      "something": "TST-01",
      "something_else": "Something else"
  },
  "_links": {
      "callback_url": "http://portal.zarafu.com/payments"
  }
 }',
CURLOPT_HTTPHEADER => array(
  'Authorization: Bearer 7NrINmYGFkhzS4sE_6OfuTRivLrbiQluQuTNBpzbMGE',
  'Accept: application/json',
  'Content-Type: application/json'
),
));
$response = curl_exec($curl);
$header_size = curl_getinfo($curl, CURLINFO_HEADER_SIZE);
$header = substr($response, 0, $header_size);
$body = substr($response, $header_size);
curl_close($curl);
//echo $response;
$headers = explode("n", $header);
echo implode($headers);

Am receiving the below header response.

HTTP/1.1 201 Created Content-Type: application/json Transfer-Encoding: chunked Connection: keep-alive Status: 201 Created Cache-Control: no-cache Referrer-Policy: strict-origin-when-cross-origin X-Permitted-Cross-Domain-Policies: none X-XSS-Protection: 1; mode=block X-Request-Id: f2a70f09-9cd5-4b85-b441-e7fa0e84b7e4 location: https://sandbox.kopokopo.com/api/v1/payments/90e02738-0d07-406b-a9c2-cf5867ad5fcf X-Download-Options: noopen X-Runtime: 0.011337 X-Frame-Options: SAMEORIGIN X-Content-Type-Options: nosniff Date: Thu, 05 May 2022 09:57:42 GMT X-Powered-By: Phusion Passenger 6.0.6 Server: nginx/1.18.0 + Phusion Passenger 6.0.6

Am only interested with the line below.

https://sandbox.kopokopo.com/api/v1/payments/90e02738-0d07-406b-a9c2-cf5867ad5fcf

Kindly assist me guys.