Q:

Pass Array to CURL - Read CSV file

My CSV has a single column with 40000 phone numbers
The following code read the CSV column and is fast
$dataArray = csvstring_to_array( file_get_contents('test.csv'));

My CURL code looks like this 
$ch = curl_init();

     $data = http_build_query($dataArray);

    curl_setopt($ch, CURLOPT_POSTFIELDS, $dataArray);
    curl_setopt($ch, CURLOPT_URL, "https://api.theblacklist.click/standard/api/v1/bulkLookup/key/[APIKEY]/response/json");
    curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
    curl_setopt($ch, CURLOPT_POST, 1);

    $output = curl_exec($ch);

The JSON parameters expected by the API look like the following. I am stuck about how to pass the "phones":[ and then pass the CSV Data array as a parameter to the curl/API?
curl -XGET ''
  -H 'Content-Type: application/json' 
  -d'
{
  "phones":[
  "15555558353",
  "15555555555",
  "15555552740",
  "15555552741",
  "15555552738"
  ]
}'

A:

It seems the API server expect JSON-formatted data to be passed as POST body
$dataArray = csvstring_to_array(file_get_contents('test.csv'));
$jsonString = json_encode(['phones' => array_values($dataArray)]);

curl_setopt($ch, CURLOPT_POSTFIELDS, $jsonString);

