Company Name to Domain with Clearbit API in PHP

This simple function allows you to pass a domain name to it and it will return a bunch of matches with domain names. In this, I’ve set it to just return the first result but you could alter. Very handy! Good time saver.

function getdomainnow($company) {

$ch = curl_init("$company");
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_HEADER, 0);
$data = curl_exec($ch);

$result = json_decode($data, true);
$result2 = [];

return $result[0];