0
我正在使用domDocument來查找html標記。domDocument編碼與數據庫不匹配
$mensaje = "Te informamos que la parada <b>Plaza de la Estación</b> está
próxima a vaciarse, el día <b>2013-04-22</b> a las <b>17:34:50</b>.";
$dom = new domDocument('1.0', 'utf8_general_ci');
// load the html into the object ***/
$dom->loadHTML($mensaje);
//discard white space
$dom->preserveWhiteSpace = false;
$nodeList= $dom->getElementsByTagName('b'); // here u use your desired tag
$items = array();
for($i=0; $i < $nodeList->length; $i++) {
$node = $nodeList->item($i);
$items[] = trim($node->nodeValue);
}
var_dump($items);
$ mensaje從我的數據庫中提取,這個字段是utf8_general_ci,但它失敗:
array(3) {
[0]=> string(21) "Plaza de la Estación"
[1]=> string(10) "2013-04-22"
[2]=> string(8) "17:34:50" }
的第一個元素有壞編碼。
我該如何解決這個問題?
添加元標記來設置內容類型。 – 2013-04-23 14:14:33