Board index   FAQ   Search  
Register  Login
Board index php forum :: php coding PHP coding => General

Changing Arrays

Ask about general coding issues or problems here.

Moderators: macek, egami, gesf

Changing Arrays

Postby bonkers » Sat Mar 15, 2003 11:01 am

I want to access all the content of an array backwards. I've come up with two possibilities.

One, I could start a loop counting backwards from the last entry in the array... but I don't know how to get the number of elements in an array.

Two, I could take all of the elements in an array and transfer them backwards to another array. Then start at one.

Any other idea's? What I have is an array where array[0] is a username and array[1] is a message...then array[2] is a username, and array[3] is the next message... I want to display the second to last array element, then the last...then the 4th to last...then the 3rd to last..etc... so all the new messages are on top.

Edit: Better yet...how do you fopen a file to add to the top...but not replace anything?
bonkers
New php-forum User
New php-forum User
 
Posts: 46
Joined: Wed Mar 12, 2003 7:17 pm

Postby Xerpher » Sat Mar 15, 2003 3:23 pm

Well I know the function array_reverse() will reverse the order of your elements... maybe that would help you.
Xerpher
New php-forum User
New php-forum User
 
Posts: 164
Joined: Tue Aug 27, 2002 8:25 pm
Location: Ontario, Canada


Return to PHP coding => General

Who is online

Users browsing this forum: No registered users and 4 guests

Sponsored by Sitebuilder Web hosting and Traduzioni Italiano Rumeno and antispam for cPanel.

cron