0
$server['s']['name'] = "§4Hello world i'm §1Mafios_X";
//

$name = $server['s']['name'];

我如何检查$name存在是否将其$4更改并在另一个(或某些)之前<font color="red">关闭标签,如果不存在任何其他标签,则在完成后关闭。</font>$4$$$name

我怎么能做到这一点?

4

1 回答 1

1

如果我很了解你

if(preg_match('/(§4)/', $name)) // if '§4' exists in $name it will go into conditional block
{
   $name = preg_replace('/(§4)/', '/<font color="red">$1<\/font>/', $str); // we replace it 
}
else
{
  //it doesn't exists
   $name.="</font>"; // we close with font tag
}

基本上这一切preg_replace('/(§4)/', '/<font color="red">$1<\/font>/', $str);都会§4改变<font color="red">§4<\/font>

于 2013-05-22T12:56:34.897 回答