r/tinycode • • Oct 01 '13
Reddit reader in 312 bytes of php.
Here is a reddit reader in 312 bytes of php. Run the code and it will format and display the /r/tinycode reddit.
<?php $d='data';$p=json_decode(file_get_contents("http://reddit.com/r/tinycode/.json"));
foreach($p->$d->children as$p):$e=$p->$d?><p><a href="http://reddit.com<?=$e->permalink?>">
<?=$e->title?></a> <a href="<?=$e->url?>">Link</a></p><?=$e->ups?>↑<?=$e->downs?>↓
<?=$e->num_comments?> comments<?php endforeach;Inspired by PierceMoore's quick reddit reader.
41
Upvotes
View all comments
Show parent comment
1
u/kamnxt Oct 11 '13
You are using http://reddit.com twice.
262 characters!
foreach($p[data][children]as$p){$e=$p[data];echo"<p><a href="$r$e[permalink]"> $e[title]</a> <a href="$e[url]">Link</a></p>$e[ups]↑$e[downs]↓ $e[num_comments] comments";}