New function to check for key existance

This commit is contained in:
Michael 2019-10-01 21:46:18 +00:00
parent c37663f1c1
commit 516fd02812

View file

@ -236,16 +236,29 @@ class CurlResult
return $this->header; return $this->header;
} }
$lines = explode("\n", $this->header); $field = strtolower(trim($field));
foreach ($lines as $line) {
$parts = explode(':', $line); $headers = self::getHeaderArray();
$headerfield = array_shift($parts);
if (strtolower(trim($field)) == strtolower(trim($headerfield))) { if (isset($headers[$field])) {
return trim(implode(':', $parts)); return $headers[$field];
} }
} }
return ''; /**
* Check if a specified header exists
*
* @param string $field header field
*
* @return boolean "true" if header exists
*/
public function headerExists(string $field)
{
$field = strtolower(trim($field));
$headers = self::getHeaderArray();
return array_key_exists($field, $headers);
} }
/** /**