Brian, you've helped me a ton! I'm wondering if you (or someone) can help me some more... There's a web page that contains this section of html:
one:{
title:"Handcuffed To A Fence In Miss.",
artist:"Jim White",
album:"No Such Place",
time:"4:07",
url:"",
filename:"Jim White - Handcuffed To A Fence In Mississippi",
trackType:"user",
visualURL:""
},
two:{
title:"Untidy Towns",
artist:"Lucksmiths",
album:"Happy Secret",
time:"2:55",
url:"",
filename:"Lucksmiths Untidy Towns",
trackType:"user",
visualURL:""
},
three:{
title:"Monkberry Moon Delight",
artist:"Paul McCartney",
album:"Ram",
time:"5:28",
url:"",
filename:"paul mccartney - monkberry moon delight",
trackType:"user",
visualURL:""
By using your method described above, I was able to successfully extract the info I needed for Track One. Here is my code:
<?php
//URL to parse
$url = 'http://www.live365.com/pls/front?handler=playlist&cmd=view&handle=glono&site=..';
//Regular expression to match the title of a document
$title = '(title:")([a-zA-Z_0-9@!%-;&,\'\+\$\.\n\t\r ]+)';
$artist = '(artist:")([a-zA-Z_0-9@!%-;&,\'+\$.\n\t\r ]+)';
$album = '(album:")([a-zA-Z_0-9@!%-;&,\'\+\$\.\n\t\r ]+)';
$time = '(time:")([a-zA-Z_0-9@!%-;&,\'+\$.\n\t\r ]+)';
//Use file() function to "grab" the page as an array
$file = @file( $url, "r" );
//Use the implode function to glue the pieces of the array together using the \n(newline) character
$target = @implode( "\n", $file);
//Use regular expression to return matches
eregi($title, $target, $match);
//This will return the title of the document
$title1 = "$match[2]";
eregi($artist, $target, $match);
$artist1 = "$match[2]";
eregi($album, $target, $match);
$album1 = "$match[2]";
eregi($time, $target, $match);
$time1 = "$match[2]";
?>
<h3>Currently playing...</h3>
<p><? echo $artist1 ; ?> - "<? echo $title1; ?>" [<? echo $time1; ?>] - <i><? echo $album1 ; ?></i></p>
It works great. See http://www.gloriousnoise.com/scripts/testradio.php to see it in action. Now I'm wondering how to get at the data for Tracks Two and Three. Any ideas?