This is a discussion on Array Problem - Help! within the PHP Language forums, part of the PHP Programming Forums category; Im having a problem with an array that is put into a session. I want to be able to remove ...
|
|||||||
| FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read |
|
|||
|
Im having a problem with an array that is put into a session. I want
to be able to remove any element, but when I loop through to display them, it doesnt work right. I believe its because of the keys associated with each element. Is there a way to reset the keys in an array back from 0 to whatever #? |
|
|||
|
Robert wrote:
> Im having a problem with an array that is put into a session. I want > to be able to remove any element, but when I loop through to display > them, it doesnt work right. I believe its because of the keys > associated with each element. Is there a way to reset the keys in an > array back from 0 to whatever #? When you delete array values it leaves a gap as you've found out. You can reindex using array_values. unset $array[$n]; $array = array_values($array); |