Hi guys, I'm kinda new in PHP and I ran into a problem. I have a script to read a RSS Feed into PHP and I want to get just a part from <link></link> This is the functions.php <?php function getFeed($feed_url) { $content = file_get_contents($feed_url); $x = new SimpleXmlElement($content); echo "<ul>"; foreach($x->channel->item as $entry) { echo " <li> <a href='$entry->link' title='$entry->title'>" . $entry->title . "</a> </li>"; } echo "</ul>"; } ?> PHP: and in index.php I have <?php getFeed("http://www.tvrage.com/myrss.php?class=scripted"); ?> PHP: In that feed the link is like <link>http://www.tvrage.com/Chuck</link> and I wonder if its possible to remove http://www.tvrage.com/ and use only Chuck. Thanks
preg_replace("<link>http:\/\/www\.tvrage\.com\/([A-Za-z]+)<\/link>","$1",$whichevervariablehasthelink); This will turn <link>http://www.tvrage.com/RegexIsAwesome</link> into RegexIsAwesome
I get an error Warning: preg_replace() [function.preg-replace]: Unknown modifier 'h' in C:\xampp\htdocs\test\2\index.php on line 26 Code (markup): preg_replace("<link>http:\/\/www\.tvrage\.com\/([A-Za-z]+)<\/link>","$1",$feed); PHP:
Most (if not all) shared hosting is running PHP, its very common place. Would you mind telling us what you did to fix it?
I know that they are running php but how about server load? If I will get more visitors will not affect the server? I've added slashes $y = preg_replace("/http:\/\/www\.tvrage\.com\/([A-Za-z]+)/","$1",$entry->link); echo "<img src='shows/$y.jpg' title='$entry->title' />"; PHP:
Most servers allow 25 simultaneous mysql connections, that is high traffic. Shared hosting can take quite a bit of traffic. A colleague of mine had a 40,000 unique serge in a day and there was no discernible problems. And thats just calls to a data base, not all php makes a request to a DB and generally there are no limits on just scripts that don't request DB info. Ultimately, check with your host for limitations. Who is your host?
For now I don't have a host but I think I choose hostgator. If you know other good hosts please let me know.
That's less a PHP variable and more a perl regex variable. Read about preg_ functions too - any info that matches whatever is within a parenthesis set is turned into a numeric variable of a number related to the order in which it was presented. But someone else could probably write that less confusingly...
My first feed parser was Magpie and it was great. But, its a heavy script with many limitations, as the more PHP I learned I eventually dropped Magpie in favor of my own custom scripts. Yeah, I've been reading a little more about that function. After wrapping my head a little more I'll be using it more often.