setting a limit to an array possible?

Discussion in 'PHP' started by gilgalbiblewheel, Sep 10, 2008.

  1. #1
    I would like to set a limit to my array. If my array has 100 items I want it to print only the first 10.
     
    gilgalbiblewheel, Sep 10, 2008 IP
  2. Steve136

    Steve136 Peon

    Messages:
    240
    Likes Received:
    15
    Best Answers:
    0
    Trophy Points:
    0
    #2
    Hi,

    Something like this?

    
    for($i=0; $i<10; $i++)
    {
        echo $yourArray[$i];
    }
    
    PHP:
    But if you mean paging, where you want to display 10 at a time, just make the number 10 a variable and change the $i dynamically, probably using $_GET[];

    Regards,

    Steve
     
    Steve136, Sep 10, 2008 IP