2012-03-09 120 views
0

所以我將例如提供這樣的代碼:使用preg_replace函數來改變在PHP <title>標籤

$str='<title>Test title here</title><meta name="description" content="test meta content here">'; 
$jftitle="here title 1"; 
$jfmeta ="here meta 2"; 

而且我有:

$str=preg_replace(array('/<title>(.*)<\/title>/i','/<meta name="description" content="(.*)">/i'),array('<title>'.$jftitle.'</title>','<meta name="description" content="'.$jfmeta.'">'),$str); 

如果我做了$海峽的回聲,它返回「」。 任何人都可以指向正確的方向嗎?

+0

適合我。 – Toto 2012-03-09 10:36:32

+0

也適合我。 – piotrekkr 2012-03-09 10:59:19

回答

1

使用echo htmlspecialchars($str);