Its my first post on the site so bear with me
Ok so i'm a complete beginner with PHP and I have a specific need for it for my project. I'm hoping some of you guys could help!
Basically, I want to scrape a webpage and access a certain html table and its information. I need to parse out this info and simply format it in a desired result.
So where to begin..... heres my php I have written so far
<?php
$url = "http://www.goldenplec.com/festivals/oxegen-2/oxegen-2011";
$raw = file_get_contents($url);
$newlines = array("\t","\n","\r","\x20\x20","\0","\x0B");
$content = str_replace($newlines, "", html_entity_decode($raw));
$start = strpos($content,'<table style="background: #FFF; font-size: 13px;"');
$end = strpos($content,'</table>',$start) + 8;
$table = substr($content,$start,$end-$start);
echo $table;
/* Regex here to echo the desired result */
?>
That URL contains the table I need. My code will simply echo that exact table.
However, and heres my problem, I'm by no means a reg-ex expert and I need to display the data from the table in a certain format. I want to echo an xml file containing a number of sql insert statements as follows:
$xml_output .= "<statement>INSERT INTO timetable VALUES(1,'Black Eyed Peas','Main Stage','Friday', '23:15')</statement>";
$xml_output .= "<statement>INSERT INTO timetable VALUES(2,'Swedish House Mafia','Vodafone Stage','Friday', '23:30')</statement>";
$xml_output .= "<statement>INSERT INTO timetable VALUES(3,'Foo Fighters','Main Stage','Saturday', '23:25')</statement>";
$xml_output .= "<statement>INSERT INTO timetable VALUES(4,'Deadmau5','Vodafone Stage','Saturday', '23:05')</statement>";
$xml_output .= "<statement>INSERT INTO timetable VALUES(5,'Coldplay','Main Stage','Sunday', '22:25')</statement>";
$xml_output .= "<statement>INSERT INTO timetable VALUES(6,'Pendalum','Vodafone Stage','Sunday', '22:15')</statement>";
I hope I have provided enough info and I would greatly appreciate any help from you kind folk.
Thanks in advance.