Regular Expression (I think)
If you have ever seen a post from me in the coding forum you will know that programming isnt exactly my strong point so I appreciate any reply......
Code:
<?php
if (isset($_GET['tag']))
{
echo '<div class="download"><a href="twitter_csv.php?tag='.$tag.'&maxpages='.$max_pages.'"><img src="download.png" /></a></div><br><div class="scroll">';
for($page = 1; $page <= $max_pages; $page++)
{
$url = "http://search.twitter.com/search.atom?lang=en&q={$tag}&rpp=100&page={$page}";
$xmlstr = file_get_contents($url);
$xml = new SimpleXMLElement($xmlstr);
foreach ($xml->entry as $entry)
{
foreach ($entry->link as $link)
{
switch((string) $link['rel']) { // Get attributes as element indices
case 'image':
$dp = $link['href'];
break;
}
}
echo '<div class="tweetScroller">
<div class="tweet">
<div class="userImage">
<a href="'.$entry->author->uri.'"><img src="'.$dp.'" alt="'.$entry->author->name.'" title="'.$entry->author->name.'" width="48px" height="48px" /></a>
</div>
<div class="date">'.$entry->updated.'</div>
<div class="content">
<a href=""><span class="username">'.$entry->author->name.'</span></a>:
'.$entry->content.'
</div>
</div>
</div>';
flush();
}
}
}
else
{
echo '<div id="about">You are limited by only being able to download a maximum of 5000 tweets. <br><br> Follow me: @moodledan</div>';
}
?>
Had some help from JackD in putting this together but ill draw your attention to the line:
Code:
<div class="date">'.$entry->updated.'</div>
This outputs: 2009-04-14T17:37:35Z
Id like it to output: 14-04-2009 <space> 17:37:35
Removing the T and Z and re-organising the layout. Now im guessing its not all possible in one simple "one liner" but if somone could:
A: Tell me where in the code to put the relevant regex
I was thinking somewhere here:
Code:
foreach ($entry->link as $link)
{
switch((string) $link['rel']) { // Get attributes as element indices
case 'image':
$dp = $link['href'];
break;
}
B: Which regex/bit of code do i need to enable me to remove the Z and T
C: Re-arrange the date?
Dan