この 3 行から Server: Microsoft-IIS/7.5 だけを取得しようとしています。コードは何ですか? それは配列です!私は print_r を使用してこの結果を取得します
Content-Type: text/html; charset=utf-8
Expires: -1
Server: Microsoft-IIS/7.5
コードはサーバーという単語を検索し、その後のすべての単語を同じ行に取得します
この 3 行から Server: Microsoft-IIS/7.5 だけを取得しようとしています。コードは何ですか? それは配列です!私は print_r を使用してこの結果を取得します
Content-Type: text/html; charset=utf-8
Expires: -1
Server: Microsoft-IIS/7.5
コードはサーバーという単語を検索し、その後のすべての単語を同じ行に取得します
その文字列が $header という名前の変数にある場合、
preg_match("/^Server: (.*)$/m", $header, $matches);
$server = $matches[1];
サーバー名を取得する必要があります
ヘッダー行が配列内にある場合のコード:
$server = NULL;
for ($i = 0; $i < count($header); $i++)
{
// Look in the line for the server header
$is_match = preg_match("/^Server: (.*)$/", $header[$i], $matches);
// $is_match holds the number of times our pattern matched (up to 1)
if ($is_match > 0)
{
$server = $matches[1];
}
}