List stuff.

    Date: 02/20/05 (PHP Community)    Keywords: no keywords

    I am trying to write a routine that displays 10 items from a list of X items. I want to be able to step through the list to see the next ten or the previous ten.

    The idea is that I have a list of X ids. I need to display a short list of them (10). I want to have a text link that says next that will get me the next 10 and a button that says back that gets me the previous 10.

    Below is the code that I thought would do that trick. It gets its input from the two text links I mentioned previously.



    $list = array();
    $list = array_fill(0, 125, 'banana');

    $separated_list = array_chunk($list, 10);

    if($_GET['mode'] == "next")
    {
    $current_list = next($separated_list);
    print "next
    ";
    }
    elseif($_GET['mode'] == "back")
    {
    $current_list = prev($separated_list);
    print "back
    ";
    }
    else
    {
    $current_list = current($separated_list);
    print "current
    ";
    }

    // output current list

    Source: http://www.livejournal.com/community/php/263579.html

« Unit tests for PHP5? || Captcha and... »


antivirus | apache | asp | blogging | browser | bugtracking | cms | crm | css | database | ebay | ecommerce | google | hosting | html | java | jsp | linux | microsoft | mysql | offshore | offshoring | oscommerce | php | postgresql | programming | rss | security | seo | shopping | software | spam | spyware | sql | technology | templates | tracker | virus | web | xml | yahoo | home