Page 1 of 1
Winamp's Now Playing Plugin: Need help with advanced array.
Posted: Fri Aug 08, 2008 3:39 am
by JAB Creations
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.
Re: Winamp's Now Playing Plugin: Need help with advanced array.
Posted: Fri Aug 08, 2008 3:47 am
by JAB Creations
Ah never mind, I did not spot their example...associative array?
I'll post my script once it's finished.

Re: Winamp's Now Playing Plugin: Need help with advanced array.
Posted: Fri Aug 08, 2008 4:12 am
by JAB Creations
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);
?>
Re: Winamp's Now Playing Plugin: Need help with advanced array.
Posted: Fri Aug 08, 2008 5:07 am
by JAB Creations
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);
?>