过滤 simplexml 结果
如何过滤结果以仅显示关键字为“848”的 torrent 我的代码
<?php
$url = "http://www.animesuki.com/xml.php?type=groups&id=1157";
$xml = simplexml_load_file($url) or die("Could not load file!");
header('Content-Type: text/xml');
echo '<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom">';
echo "<channel>";
$i = 0;
foreach ($xml->release as $getrelease => $value)
{
if (++$i > 10) {
break;
}
echo "<item>";
echo "<title>".$getrelease->filename."</title>";
echo "<link>".$getrelease->torrent[0]->direct."</link>";
echo "</item>";
}
echo "</channel>";
?>
谢谢
how to filter the result to show only torrent with keyword "848"
my code
<?php
$url = "http://www.animesuki.com/xml.php?type=groups&id=1157";
$xml = simplexml_load_file($url) or die("Could not load file!");
header('Content-Type: text/xml');
echo '<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom">';
echo "<channel>";
$i = 0;
foreach ($xml->release as $getrelease => $value)
{
if (++$i > 10) {
break;
}
echo "<item>";
echo "<title>".$getrelease->filename."</title>";
echo "<link>".$getrelease->torrent[0]->direct."</link>";
echo "</item>";
}
echo "</channel>";
?>
thank
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
有多种方法可以做到这一点。
1) 例如,如果文件名应该仅包含关键字848;你应该这样做:
2)如果你还想匹配 foobar848 和 bla848blabla,你应该使用正则表达式:
但我想这是非常基本的 PHP 东西,如果你不理解 if 循环的概念,也许你应该先读一些书:)。
There are multiple ways to do this.
1) if for example the filename should only contain the keyword 848; you should do this:
2) if you also want to match foobar848 and bla848blabla, you should use a regular expression:
But I guess this is very basic PHP stuff, if you don't understand the concept of an if-loop, maybe you should read some books first :).