Hi -- I am still in the very early stages of learning PHP. I'm building a site for a client and they've asked me to create a script that's beyond my current abilities.
I'm trying to figure out whether it's something that I could understand and build in a couple of days or whether I should just move on and hire a subcontractor to code it. I would rather build it myself for the sake of learning, but if it's going to take hours and hours, I'd rather just pay someone and not stress out over it.
Here's what I'm trying to do and where I am:
fetch the contents of an external text file
examine each line to see if it matches a regex
break the line into two parts: a three-digit number and a URL
each URL is for an RSS feed, for which I need to fetch the title and description [is there built-in functionality to grab this info?]
display the number and the RSS info as HTML
I can get as far as step 3 without any problems but my method for step 4 is getting me nowhere.
Here is the code I have so far:
$lines = file('file.txt');
foreach ($lines as $line) {
if (ereg('^[0-9][0-9][0-9] http://.+' , $line)) {
$url = (ereg_replace('^[0-9][0-9][0-9] (http://.+)' , '\1' , $line));
$num = (ereg_replace('^([0-9][0-9][0-9]) http://.+' , '\1' , $line));
$rss = simplexml_load_file($url);
foreach($rss->channel as $channel) {
echo '<h3>' . "$num " . $channel->title . '</h3>';
echo '<p>' . $channel->description . '</p>';
}
}
This works for a few of the feeds but for most of them it returns the error "Warning: simplexml_load_file() [function.simplexml-load-file]: I/O warning : failed to load external entity ""
When it is returning the URL in the error, each one has the characters "%0A" on the end.
I also get a "Fatal error: Maximum execution time of 30 seconds exceeded" which is probably because there are a couple hundred URLs to be processed.
Any help or pointers would be much appreciated.
OTOH, if you think I'm just setting myself up for pain, can you suggest a good place to hire a coder to do the job?
Thanks.