ใช้ dom ดึงภาษาไทยออกมามันไม่เป็นภาษาเลยครับ

เริ่มโดย sakang, 05 พฤศจิกายน 2012, 20:53:26

หัวข้อก่อนหน้า - หัวข้อถัดไป

0 สมาชิก และ 1 ผู้มาเยือน กำลังดูหัวข้อนี้

sakang

ที่ดึงได้มาเป็นแบบนี้อะครับ

อ้างถึงร ยนย€ร ยธยฃร ยธยดร ยนยˆร ยธยกร ยธย—ร ยธยตร ยนยˆ 699 ร ยธยชร ยธยณร ยธยซร ยธยฃร ยธยฑร ยธยšร ยนย€ร ยธยร ยธยกร ยธยชร ยนยŒร ยนย‚ร ยธย"ร ยธยขร ยนย€ร ยธย‰ร ยธยžร ยธยฒร ยธยฐ ร ยธยžร ยธยฃร ยนย‰ร ยธยญร ยธยกร ยนยƒร ยธยซร ยนย‰ร ยธยšร ยธยฃร ยธยดร ยธยร ยธยฒร ยธยฃ

ที่เคยใช้แปลง

$pf2 = mb_convert_encoding($pf2, 'utf-8', mb_detect_encoding($pf2));
$pf2 = mb_convert_encoding($pf2, 'html-entities', 'utf-8');


ใครพอช่วยได้บ้างครับ

zest_th

ลองใช้คำสั่งนี้หรือยังครับ 

mysql_query("SET NAMES 'utf8';");

sakang


dekmv


marus


goldxp

พยายามเปลี่ยน string เป็น utf8 ก่อนครับ

dom.php

<?php

header
('content-type:text/html;charset=utf-8');
$dom = new DOMDocument('1.0','UTF-8');
$source '<root><name>doraemon</name><name>โดเรม่อน</name></root>';
//$source = iconv('TIS-620','UTF-8',$source);
$dom->loadXML($source);
$e $dom->getElementsByTagName('name');
echo 
$e->item(1)->textContent;

?>

[direct=http://web-programming-bookmark.blogspot.com/p/blog-page.html]รับแก้ไขเว็บ[/direct]

kuznetsova

เว็บที่ทำจาก Blogger สวยงามได้แค่ไหนชม
[direct=https://www.forexfights.com]วิธีเทรดฟอเร็กซ์ กรอบเวลาต่างๆ[/direct]
[direct=https://babbaan.in]แบบบ้านความรู้เรื่องบ้าน[/direct]
[direct=http://www.herb-health.com]แบบทรงผมข้อมูลด้านสุขภาพ ความงาม[/direct]

infamous

อ้างถึงจาก: kuznetsova ใน 06 พฤศจิกายน 2012, 06:57:24
อันนี้น่าจะดีกว่าครับผมใช้อยู่

http://simplehtmldom.sourceforge.net/manual.htm

confirm  :wanwan003:

/* simple and easy */
* dom.php
*/
<?php
require_once('simple_html_dom.php');

$html file_get_html('http://www.thaiseoboard.com');

echo 
'<ul>';

foreach(
$html->find('table.ssi_table tr td a[target=_blank]') as $element) {
   echo 
'<li><a href="',$element->href,'">',$element->plaintext,'</a></li>';   
}
echo 
'</ul>';

$html->clear();
unset(
$html);
?>


seonew