diff options
-rw-r--r-- | index.php | 11 |
1 files changed, 9 insertions, 2 deletions
@@ -107,9 +107,16 @@ if ($news32 === false) { print " </h4>\n"; } else { foreach($news32 -> {'entry'} as $entry) { + $content = $entry -> {'summary'} -> __toString(); + if (preg_match('#^<p>By [^<]*<br />On ([0-9]+)/([0-9]+)/([0-9]+), [^<]+</p>.*$#', $content) == false) + $date = explode('T', $entry -> {'updated'} -> __toString())[0]; + else { + $date = preg_replace('#^<p>By [^<]*<br />On ([0-9]+)/([0-9]+)/([0-9]+), [^<]+</p>.*$#', '\3-\1-\2', $content); + $content = preg_replace('#^<p>By [^<]*<br />On [^<]*</p>#', '', $content); + } $news[] = array ( - 'content' => preg_replace('#^<p>By [^<]*<br />On [^<]*</p>#', '', $entry -> {'summary'} -> __toString()), - 'date' => explode('T', $entry -> {'updated'} -> __toString())[0], + 'content' => $content, + 'date' => $date, 'link' => $entry -> {'link'} -> attributes() -> {'href'} -> __toString(), 'title' => $entry -> {'title'} -> __toString() ); |