bo5ton — 2012-03-28T20:37:11-04:00 — #1
I'm using the Simplehtmldom parser to grab linked headlines from a site, but there are many links on the pages and my script is returning all of them. I'm wondering how I can change it to only return the first 5 links instead of the whole lot.
Here is my code:
$url = "websitehere";
$html = file_get_html($url);
$data = $html->find('div[class=content] a');
Any help is greatly appreciated.
bo5ton — 2012-03-29T00:24:55-04:00 — #2
I thought about using something like
array_slice($data, 0, 5);
but it doesn't work (i don't really know what i'm doing).