This section allows you to view all posts made by this member. Note that you can only see posts made in areas you currently have access to.
181
Off-topic / Re: json_decode and arrays
« on May 31st, 2013, 03:05 AM »
How can I remove an "object" from JSON input if
Code: [Select]
... is present in that object? To be clear, the right fragment is how it should be treated :) http://diffchecker.com/c9ha939m
"@attr":{
"nowplaying":"true"
}
... is present in that object? To be clear, the right fragment is how it should be treated :) http://diffchecker.com/c9ha939m
182
Off-topic / Re: json_decode and arrays
« on May 30th, 2013, 11:10 PM »
Yay, now works :)
Code: [Select]
else {
$data = json_decode(file_get_contents($json), true);
file_put_contents($cache_lastfm,json_encode($data));
}
183
Off-topic / Re: json_decode and arrays
« on May 30th, 2013, 08:06 PM »
Thanks for the clarification. :)
I'm trying to add a caching mechanism.. local .json file is created, but "null" is its content :P
Code: [Select]
What's wrong with this?
I'm trying to add a caching mechanism.. local .json file is created, but "null" is its content :P
$json = "http://pastebin.com/NLHGMapT";
$cache_lastfm = 'BLAHBLAH/'.sha1($json).'.json';
if(file_exists($cache_lastfm) && filemtime($cache_lastfm) > time() - 1000){
// if a cache file newer than 1000 seconds exists, use it
$data = json_decode(file_get_contents($cache_lastfm, true));
} else {
$data = json_decode($json, true);
file_put_contents($cache_lastfm,json_encode($data));
}What's wrong with this?
184
Off-topic / Re: json_decode and arrays
« on May 30th, 2013, 07:46 PM »
Uh, thanks. And are they the same in this case (dots and commas)?
185
Off-topic / Re: Next System Visitation
« on May 30th, 2013, 07:39 PM »
Voted for IPB. Seems the best competitor IMHO..
186
Off-topic / Re: json_decode and arrays
« on May 30th, 2013, 06:58 PM »Well, apart from the indentation and multiple echos... :^^;:
187
Off-topic / Re: json_decode and arrays
« on May 30th, 2013, 06:04 PM »
This appears to be working :)
Code: [Select]
Can be improved or is it ok?
<ul>
<?php
$json = file_get_contents('http://pastebin.com/NLHGMapT');
$data = json_decode($json, true);
$data = $data['recenttracks'];
foreach ($data['track'] as $track) {
$artist = $track['artist']['#text'];
$title = $track['name'];
$url = $track['url'];
echo '<li><a href="'; echo $url; echo '" title="'; echo $title; echo '">'; echo $artist; echo ' - '; echo $title; echo '</li></a>'; }
?>
</ul>
Can be improved or is it ok?
188
Plugins / [Plugin] Re: Notifications system (1.0)
« on May 28th, 2013, 06:34 PM »Actually, I added a 0.3s delay to avoid sending needless Ajax requests to the server... ;)
189
Plugins / [Plugin] Re: Notifications system (1.0)
« on May 28th, 2013, 06:19 PM »
Uhm.. I don't know.. I think I like this version too. Maybe the only note is that it takes almost 1 second the first time to load the animation...
190
Off-topic / Re: System visitations: MyBB 1.6.10
« on May 28th, 2013, 06:01 PM »
Ugly is a kind word ahah
191
The Pub / Re: Not using version numbers as such
« on May 28th, 2013, 01:58 PM »Because I don't want to copy phpBB ;)
192
The Pub / Re: Not using version numbers as such
« on May 28th, 2013, 12:53 PM »
Since it's a "European" product, why not something from the cradle of our culture :D http://en.m.wikipedia.org/wiki/List_of_Greek_mythological_figures
193
Off-topic / Re: json_decode and arrays
« on May 25th, 2013, 12:29 PM »First glance says that you need to check !empty($data) then foreach ($data->track as $track) then you can iterate over $track to get artist and whatnot.
Possibly you might find it easier to wade through if you pulled it back from json_decode as an associative array rather than an object.
$json = file_get_contents('http://pastebin.com/NLHGMapT');
$arrayObjects = json_decode($json, true);194
Off-topic / json_decode and arrays
« on May 24th, 2013, 05:06 PM »<?php
$json = file_get_contents('http://pastebin.com/NLHGMapT');
$track_data = json_decode($json);
?>
<?php
echo '<ul>';
foreach ($track_data as $data)
{
if (!empty($data)) {
$text = $data->track[0]->artist->{'#text'};
}
echo '<li><span>'; echo $text; echo '</span></li>';
}
echo '</ul>';
?>How can I have $text for every array (track[0], track[1], track[2], track[n]) in respective <li>s?
195
Off-topic / Re: jQuery(document).ready function issue
« on May 14th, 2013, 07:33 AM »
Hi!
Thanks for the reply and your advices! :-) Probably it's a misleading title.. you can see the code I'm talking about here: http://goo.gl/uuv5y
Unfortunately because it's a live site I only left the first part and removed the TPL one..
Thanks for the reply and your advices! :-) Probably it's a misleading title.. you can see the code I'm talking about here: http://goo.gl/uuv5y
Unfortunately because it's a live site I only left the first part and removed the TPL one..