これは、私がこのようなことのためにいつも使っている本当にシンプルで便利な関数です。
<?php
function get_string_between($string, $start, $end){
$string = " ".$string;
$ini = strpos($string,$start);
if ($ini == 0) return "";
$ini += strlen($start);
$len = strpos($string,$end,$ini) - $ini;
return substr($string,$ini,$len);
}
$src = "Host: xxx.com, IP address: 37.0.122.151, SBL: SBL196170, status: unknown, level: 4, Malware: Citadel, AS: 198310, country: RU";
//add a character to src to help identify the last field
$src = $src.",";
$host = get_string_between($src, "Host: ", ","); //this is grabbing any text between "Host: " and ","
$ip = get_string_between($src, "IP address: ", ",");
$SBL = get_string_between($src, "SBL: ", ",");
$status = get_string_between($src, "status: ", ",");
$level = get_string_between($src, "level: ", ",");
$malware = get_string_between($src, "Malware: ", ",");
$as = get_string_between($src, "AS: ", ",");
$country = get_string_between($src, "country: ", ",");
?>
ハッピーコーディング!