나는 아래의 예와 같은 항목의 수와 XML 파일을 만든 :랜드() 셔플 XML 출력
<?xml version="1.0" encoding="UTF-8"?>
<feed xmlns="http://www.w3.org/2005/Atom">
<id>http://www.example.com/index.php?pagina=video-categories</id>
<title><![CDATA[Example.com Categories RSS]]></title>
<author>
<name>Example.com</name>
<email>[email protected]</email>
</author>
<updated></updated>
<link rel="alternate" href="http://www.example.com/categories"/>
<subtitle><![CDATA[HQ example videos in any category]]></subtitle>
<rights>Copyrights reserved. Feel free to use the embed function.</rights>
<item>
<categoryname><![CDATA[100 Latest Videos]]></categoryname>
<shortcategoryname><![CDATA[100 New Sex Clips]]></shortcategoryname>
<categoryurl>http://www.example.com/1.html</categoryurl>
<categoryimage>http://www.example.com/12347.jpg</categoryimage>
</item>
<item>
<categoryname><![CDATA[100 Latest Videos]]></categoryname>
<shortcategoryname><![CDATA[100 New Sex Clips]]></shortcategoryname>
<categoryurl>http://www.example.com/2.html</categoryurl>
<categoryimage>http://www.example.com/12346.jpg</categoryimage>
</item>
<item>
<categoryname><![CDATA[100 Latest Videos]]></categoryname>
<shortcategoryname><![CDATA[100 New Sex Clips]]></shortcategoryname>
<categoryurl>http://www.example.com/3.html</categoryurl>
<categoryimage>http://www.example.com/12345.jpg</categoryimage>
</item>
... and more items ...
</feed>
I XML 파일에서 출력으로 모든 링크에 다음 코드를 가지고
<?php
$html = ""; // var full of emptyness
$url = "http://www.example.com/categories.xml";
$xml = simplexml_load_file($url);
for($i = 0; $i < 35; $i++){ // Number of category here, I use a lower number at this moment...
$categoryname = $xml->item[$i]->categoryname;
$shortcategoryname = $xml->item[$i]->shortcategoryname;
$categoryurl = $xml->item[$i]->categoryurl;
$html .= '<a class="purplewidebutton" href="' . $categoryurl . '" title="' . $categoryname . '">' . $shortcategoryname . '</a>';
}
echo $html;
?>
6 개의 링크 만 표시하고 XML 피드에서 위치 정보를 표시하고 싶습니다. xml 항목에서 임의의 링크를 갖고 싶습니다. 어떤 항목을 추가하거나 변경해야합니까? rand()
또는 shuffle()
을 6 개의 무작위 링크에 에코하려면 사용해야합니까?
PHP 코드가 좀 링크를 반향이 순간에 사용하고 무엇을하지만 그렇지 않은 임의의 ...
보유하고있는 PHP는 무엇입니까? – AbraCadaver
내 질문에 표시된 PHP 코드를 사용하지만 xml 파일 URL은 실제 URL이 아니라 예제 URL입니다. – jagb
죄송합니다. 스크롤하지 않았습니다. – AbraCadaver