我正在尝试从数据库中获取事件名称(例如:Manny Pacquiao vs. Juan Manuel Marquez),将事件名称拆分为 2 个名称(Manny Pacquiao、Juan Manuel Marquez)并在页面上使用它们。
这是我的代码不起作用。
if(count($perfarray) == 2 && $page['catnum'] == "1142")
{
$input = $event['Event'];
$params = explode('vs.', $input);
foreach($params as $param)
{
$kv = explode('vs.', $param);
$fighterNo1 = $kv[0];
$fighterNo2 = $kv[1];
}
$fulltext = str_replace("\$Fighter1", $fighterNo1, $fulltext);
$fulltext = str_replace("\$Fighter2", $fighterNo2, $fulltext);
// $fulltext = str_replace("\$Fighter1", addslashes($perfarray[0]), $fulltext);
//$fulltext = str_replace("\$Fighter2", addslashes($perfarray[1]), $fulltext);
}
elseif(strstr($event['Event']," vs."))
{
$input = $event['Event'];
$params = explode('vs.', $input);
foreach($params as $param)
{
$kv = explode('vs.', $param);
$fighterNo1 = $kv[0];
$fighterNo2 = $kv[1];
}
$fulltext = str_replace("\$Fighter1", $fighterNo1, $fulltext);
$fulltext = str_replace("\$Fighter2", $fighterNo2, $fulltext);
}