SitePoint Sponsor

User Tag List

Results 1 to 2 of 2

Hybrid View

  1. #1
    Quality not quantity. bo5ton's Avatar
    Join Date
    Oct 2003
    Location
    Australia
    Posts
    654
    Mentioned
    3 Post(s)
    Tagged
    0 Thread(s)

    Simplehtmldom - limit return

    Hi all..

    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:

    PHP Code:
    <?php

    include_once 'simplehtmldom/simple_html_dom.php';
     
    $url "websitehere";
     
    $html file_get_html($url);

    $data =  $html->find('div[class=content] a');

    if(isset(
    $data[0]))
        echo 
    $data[0]->children(1);

    print 
    "$html";

    ?>
    Any help is greatly appreciated.

  2. #2
    Quality not quantity. bo5ton's Avatar
    Join Date
    Oct 2003
    Location
    Australia
    Posts
    654
    Mentioned
    3 Post(s)
    Tagged
    0 Thread(s)
    I thought about using something like

    PHP Code:
    array_slice($data05); 
    but it doesn't work (i don't really know what i'm doing).


Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •