Parsing MochiAds feed in a friendly way
- August 28, 2008 by Emanuele Feronato
- Filed under Php | 9 Comments
I made this little script to debug my portal script (almost completed) and I want to share it with you.
It simply shows MochiAds feed in a friendly way, using lists.
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 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 | <?php $mochi_url = "http://www.mochiads.com/feeds/games?format=json"; $feed = file_get_contents($mochi_url); $games_array = json_decode($feed, true); $number_of_games = count($games_array[games]); echo "<ol>"; for($x=0;$x<$number_of_games;$x++){ echo "<li><ul>"; foreach($games_array[games][$x] as $varname => $varvalue) { echo "<li><strong>$varname</strong>: "; if(is_array($varvalue)){ echo "<ol>"; foreach($varvalue as $subvar => $subvalue){ echo "<li>"; if(is_array($subvalue)){ foreach($subvalue as $lastvar => $lastvalue){ echo "$lastvalue"; if(!$lastvar){ echo ": "; } } } else{ echo "$subvalue"; } echo "</li>"; } echo "</ol>"; } else{ if(strpos($varvalue,"http")!==false){ echo "<a href = \"$varvalue\" target = \"_blank\">$varvalue</a>"; } else{ echo $varvalue; } } echo "</li>"; } echo "</ul></li>"; } echo "</ol>"; ?> |
Hope you will find it useful.
9 Responses
Leave a Reply
TUTORIAL SERIES:
- Una guida completa al gioco del poker online e una selezione dei migliori casino online.
- casino online
- migliori casino online
- BlackJack online
- casinò online


(2 votes, average: 3.50 out of 5)

When I run the page I get a undifined function call at line 5.
That’s because your hosting server does not support Php 5.2
What if we get a memory error?
cheap server…
[...] hosting plan can handle enough work, you should at least be able to run the script published in Parsing MochiAds feed in a friendly way or you won’t be able to have your WordPress arcade [...]
Wow Emanuele, you know so many languages O_o
nice for testing, thanks!
Another solution :)
<img src="” alt=”"/>
<a href="page_detail.php?game_name=”>
Controls:
Tag:
Game_id:
I was just starting to work on something like this….It looks good.