Re: safe to delete elements of array in foreach
- From: ZeldorBlat <zeldorblat@xxxxxxxxx>
- Date: 18 May 2007 08:10:18 -0700
On May 18, 11:05 am, "Jon Slaughter" <Jon_Slaugh...@xxxxxxxxxxx>
wrote:
Is it safe to remove elements from an array that foreach is working on?
(normally this is not the case but not sure in php) If so is there an
efficient way to handle it? (I could add the indexes to a temp array and
delete afterwards if necessary but since I'm actually working in a nested
situation this could get a little messy. I guess I could set there values to
null and remove them afterwards?
Thanks,
Jon
Why don't you try it and see what happens?
.
- Follow-Ups:
- Re: safe to delete elements of array in foreach
- From: Jon Slaughter
- Re: safe to delete elements of array in foreach
- References:
- safe to delete elements of array in foreach
- From: Jon Slaughter
- safe to delete elements of array in foreach
- Prev by Date: safe to delete elements of array in foreach
- Next by Date: Re: Getting two variables from a PHP loop
- Previous by thread: safe to delete elements of array in foreach
- Next by thread: Re: safe to delete elements of array in foreach
- Index(es):