Re: Looping through array

From: Date: Thu, 16 Nov 2006 21:14:48 +0000
Subject: Re: Looping through array
References: 1  Groups: php.general 
Request: Send a blank email to php-general+get-244751@lists.php.net to get a copy of this message
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

« previous php.general (#244751) next »