Re: Looping through array

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



At 1:19 PM -0700 11/16/06, Ashley M. Kirchner wrote:
Say I have an array containing ten items, and I want to display them in a table as follows:

    5 4 3 2 1
   10 9 8 7 6

What's the best way to loop through that array to do that? My thinking gets me to create a loop for 5 through 1, repeated twice, and the second time I add '5' to the index value. There's got to be a saner way...

Ashley:

Look into array_chunk() and array_flip(). The first can break your main array into two and the second can reverse the results.

tedd

--
-------
http://sperling.com  http://ancientstones.com  http://earthstones.com

--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


[Index of Archives]     [PHP Home]     [Apache Users]     [PHP on Windows]     [Kernel Newbies]     [PHP Install]     [PHP Classes]     [Pear]     [Postgresql]     [Postgresql PHP]     [PHP on Windows]     [PHP Database Programming]     [PHP SOAP]

  Powered by Linux