Limit Output in Glob()?

Discussion in 'PHP' started by Stace, Feb 5, 2012.

  1. #1
    Hi

    I am pulling thumbs from a directory with the following function:

    Can you tell me how to limit the number of thumbs that this displays please? ( Lets say, only display 10 thumbs )

    Thanks so much, here is the code

    <?php
    $largeArray = glob("images/*.jpg");
    $counter = 0; 
    foreach (glob("images/thumbs/*.jpg") as $thumb)
    {
    echo ("<div class='thumbnail'><a href='$largeArray[$counter]'><img src='$thumb'/></a></div>");
    $counter++;
    }
    ?>
    
    PHP:
     
    Stace, Feb 5, 2012 IP