1. Advertising
    y u no do it?

    Advertising (learn more)

    Advertise virtually anything here, with CPM banner ads, CPM email ads and CPC contextual links. You can target relevant areas of the site and show ads based on geographical location of the user if you wish.

    Starts at just $1 per CPM or $0.10 per CPC.

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