##ถามเซียนPHPเป็นภาษาต่างดาว แก้ยังไงครับ ดึงRSSมาแล้ว อ่านไม่ออก +1

เริ่มโดย danisthai, 13 สิงหาคม 2013, 19:50:08

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

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

danisthai

เซียนๆphp ใครพอทราบบ้าง  แก้ยังไงครับ   :wanwan017:
สอบถามPHPเป็นภาษาต่างดาว  ดึงRSS.xmlมาแสดงผลในเว็บแล้ว  แต่อ่านไม่ออก  ดังรูปครับ



มีแค่2ไฟล์  ดังนี้ครับ
index.php

<div>
 <?php
  
include('rssclass.php');
  
$feedlist = new rss('http://www.mywebsite.com/rss/news.xml');
  echo 
$feedlist->display(5,"ทันต่อเหตุการณ์");
 

  
?>

 </div>




rssclass.php

<?php
 
class rss {
     var 
$feed;

  function 
rss($feed
    {   
$this->feed $feed;  }
 
  function 
parse() 
    {
    
$rss simplexml_load_file($this->feed);
    
    
$rss_split = array();
    foreach (
$rss->channel->item as $item) {
    
$title = (string) $item->title// Title
    
$link   = (string) $item->link// Url Link
    
$description = (string) $item->description//Description
    
$rss_split[] = '<div>
        <a href="'
.$link.'" target="_blank" title="" >
            '
.$title.
        </a>
   <hr>
          </div>
'
;
    }
    return 
$rss_split;
  }
  function 
display($numrows,$head
  {
    
$rss_split $this->parse();

    
$i 0;
    
$rss_data '<div class="vas">
           <div class="title-head">
         '
.$head.'
           </div>
         <div class="feeds-links">'
;
    while ( 
$i $numrows 
   {
      
$rss_data .= $rss_split[$i];
      
$i++;
    }
    
$trim str_replace('''',$this->feed);
    
$user str_replace('&lang=en-us&format=rss_200','',$trim);
    
$rss_data.='</div></div>';
    return 
$rss_data;
  }
}
?>




เซียนๆphp ใครพอรู้ไหมครับ   แก้ยังไง  +1 ขอบคุณครับ   :wanwan017:

UnzO

สั่ง Encoding หน้าที่ Display เป็น UTF-8 แล้วยังครับ

<meta http-equiv="Content-Type" content="text/html; charset=utf-8">

danisthai

อ้างถึงจาก: UnzO ใน 13 สิงหาคม 2013, 19:56:26
สั่ง Encoding หน้าที่ Display เป็น UTF-8 แล้วยังครับ

<meta http-equiv="Content-Type" content="text/html; charset=utf-8">

สั่งแล้วครับ  แบบนี้ใช่ไหมครับ
ผมใส่ไว้บนHead  แบบนี้ใช่ไหมครับ 

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=tis-620" />
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />

<title>Title</title>
<link rel="stylesheet" href="tr.css" type="text/css">
</head>

แต่ไม่ได้ผล
ขอบคุณมากครับ
:wanwan017:

kppser


UnzO