preg_match question... or problem :)

[php]
include ‘website_parser.php’;

//Instance of WebsiteParser
$parser = new WebsiteParser(‘http://www.sportingnews.com/nfl’);

//Get all hyper links
$links = $parser->getHrefLinks();
foreach ($links as $link) {
foreach ($link as $html) {
//preg_match(’/nfl/’, $html, $content)

//Get all image sources
//$images = $parser->getImageSources();

echo “

”;
print_r($html);
//echo “
”;
//print_r($images);
//echo “
”;
?>

<a href=<"<?= $html ?>">read more here

<?php } } [/php] That is my code and it returns this:
http://www.sportingnews.com//newsletter/signup?iadid=Nav_SUBSCRIBE_NEWSLETTER read more here Subscribe to Newsletter read more here http://core.adtech.com/adlink/3.0/5452.1/0/0/-1/ADTECH;loc=300;grp=528007745;alias=nflhomeTOP;random=517529966 read more here Image:ADTECH;loc=300;grp=528007745;alias=nflhomeTOP;random=517529966 read more here http://www.sportingnews.com/nfl/story/2015-03-09/ndamukong-suh-miami-dolphins-contract-salary-amount-cap-space-detroit-lions-value-defense-ranking-details-tackle-stats read more here Read more read more here http://www.sportingnews.com/nfl/story/2015-03-08/nfl-free-agency-live-blog-rumors-signings-analysis-deals-suh-murray-mccourty-hardy-maxwell-maclin read more here Read more read more here http://www.sportingnews.com/nfl/story/2015-03-09/nfl-free-agency-2015-tobais-palmer-buffalo-bills-jaguars-saints-chargers-nc-state read more here Read more read more here
from here: http://www.sportingnews.com/nfl I'm trying to get preg_match to work here so I can just get the links that start with this:
http://www.sportingnews.com/nfl/story/
I have read and read and can't get it to work for some reason... I've tried matchin '/nfl/' against the $html variable but it returns 'nfl' in the array and that's it... LOL Go figure... SO apparently I'm not doing it right .... anyone have a suggestion to get this working or is using preg_match the wrong idea here? Thanks!

you could try an old fashioned strpos.

if(strpos(link, ‘ttp://www.sportingnews.com/nfl’))

*note dropping the first letter intentionally

Thank you!

Sponsor our Newsletter | Privacy Policy | Terms of Service