I am trying to parse some data from external site to local script. Local script cals remote page with some get data to initiate response.
Returning the required data in the headers of the remote script, in this case data is “key” string.
Now the remote page also outputs a load of other headers, the one we are after is called LicenceID
unfourtunalty the array crerated by get_headers seems to include the header title in the value, not the key. So am trying some regex to match the header value, which would look somthing like this:
licenceID: dfkfdlsdlghgsldghsld
function check_path($path)
{
$headers = @get_headers($path);
var_dump($headers);
//while (list($key, $value) = each($headers))
foreach($headers as $key => $value)
{
echo "$key - $value<br />";
//if(preg_match('/^.*licenceID:*$/',$value))
if (preg_match('/^.*licenceID.*$/i', $dictionary, $matches))
{
echo "found";
echo "$key - $value<br />";
$position = strpos($value, ':');
$clean_value = substr($value, $position);
$clean_up = trim_string($clean_value,":");
return $clean_up;
}
else
{
return false;
}
}
}
Having trouble with the regex in the line if (preg_match(‘/^.licenceID.$/i’, $dictionary, $matches))
cant seem to get it to match, also needs to strip out the licenceID: from the value and only return the data after the :
Suggestions welcome!
You could just use substr():