-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathatom.php
30 lines (25 loc) · 844 Bytes
/
atom.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
<?php
function atom($url)
{
$xml = simplexml_load_string(file_get_contents($url));
if (empty($xml->entry))
return;
foreach($xml->entry as $e)
{
echo '<div class="postdate">'.date('l, F j, Y', strtotime($e->published))."</div>";
echo '<h3>';
foreach($e->link as $l)
{
$rel = $l->attributes()->rel[0];
if ($rel == '' || $rel == 'alternate')
{
$link = '<a href="'.$l->attributes()->href[0].'">';
break;
}
}
echo $link.$e->title."</a></h3>\n";
echo '<div class="post">'.substr(strip_tags($e->content), 0, 300);
echo $link."...</a></div>\n";
}
}
?>