The Now Playing plugin is configured to send an array of data to a file on my website via $_POST request.
Here is what that data's structure looks like...
http://users.jyu.fi/~ltnevala/nowplayin ... parameters
I'm a little bit baffled as how to access any part of this array...or subarrays. Could someone please fill me in on what their array setup is referred to as so I could do a little reading?
In essence I'd like to assign a song name to a variable. If I know how to do that I would know how to work with this sort of array just fine.
Winamp's Now Playing Plugin: Need help with advanced array.
Moderator: General Moderators
- JAB Creations
- DevNet Resident
- Posts: 2341
- Joined: Thu Jan 13, 2005 6:44 pm
- Location: Sarasota Florida
- Contact:
- JAB Creations
- DevNet Resident
- Posts: 2341
- Joined: Thu Jan 13, 2005 6:44 pm
- Location: Sarasota Florida
- Contact:
Re: Winamp's Now Playing Plugin: Need help with advanced array.
Ah never mind, I did not spot their example...associative array?
I'll post my script once it's finished.
I'll post my script once it's finished.
- JAB Creations
- DevNet Resident
- Posts: 2341
- Joined: Thu Jan 13, 2005 6:44 pm
- Location: Sarasota Florida
- Contact:
Re: Winamp's Now Playing Plugin: Need help with advanced array.
If I change the fopen mode from x to w it writes to the file...but I don't want to clear the file's contents! It does nothing when using x but it's the only mode listed on php.net that does not delete the contents and writes to the file at the beginning. Suggestions?
Code: Select all
<?php
$fp = fopen('winamp.txt', 'x');
for($i = 0; $i < count($_POST['Song']);$i++)
{
$artist = $_POST["Song"][$i]["Artist"];
$album = $_POST["Song"][$i]["Album"];
$title = $_POST["Song"][$i]["Title"];
$update = $artist.' - '.$album.' - '.$title."\n";
fwrite($fp, $update);
}
fclose($fp);
?>- JAB Creations
- DevNet Resident
- Posts: 2341
- Joined: Thu Jan 13, 2005 6:44 pm
- Location: Sarasota Florida
- Contact:
Re: Winamp's Now Playing Plugin: Need help with advanced array.
Well I've confirmed that the file isn't being opened even though it has a CHMOD of 777 (I usually only do 646 though but this is testing)...
Code: Select all
<?php
function file_error()
{
$fp = fopen('winamp.txt', 'w');
$update_now = fwrite($fp, "an error ocurred!");
fclose($fp);
}
$fp = fopen('winamp.txt', 'x+');
if (!$update_now) {file_error();}
for($i = 0; $i < count($_POST['Song']);$i++)
{
$artist = $_POST["Song"][$i]["Artist"];
$album = $_POST["Song"][$i]["Album"];
$title = $_POST["Song"][$i]["Title"];
$update = $artist.' - '.$album.' - '.$title."\n";
$update_now = fwrite($fp, $update);
}
fclose($fp);
?>