# removing an item from an array

- Thread: https://externals.io/message/62386
- Original archive: https://news-web.php.net/php.internals/62386
- Started by Andrew Faulds on 2012-08-22T06:50:54+00:00
- Messages: 2
- Reply by email to internals@lists.php.net
- More for agents: search with https://externals.io/search.md?q={query} · JSON API at https://externals.io/api · documentation at https://externals.io/llms.txt

---

## #62386 — Andrew Faulds — 2012-08-22T06:50:54+00:00

URL: https://externals.io/message/62386#62386

Um, Yasuo, have you looked at array_walk implementation and ascertained it is safe to change array structure while using it?

Because I'm worried you're changing docs without doing so.

--
Sent from Samsung Mobile
Andrew Faulds
http://ajf.me/

Yasuo Ohgaki <yohgaki@ohgaki.net> wrote:

Hi,

2012/8/22 Levi Morrison <morrison.levi@gmail.com>:
> 
> > […]
>
> Take a look at:
> http://php.net/manual/en/function.array-walk.php#refsect1-function.array-walk-parameters
>
> Look at funcname parameter.  Notice:
> > […]
>
> I'm just going to change the behavior back when you switch it to
> array_walk. It's less clear and technically undefined.

Ok, then my commit to the doc was outstanding still.
Old PHP was behaved badly with reference variables.
I'll remove obsolete statement.

I'll fix it later.
Thank you.

--
Yasuo Ohgaki
yohgaki@ohgaki.net

---

## #62415 — Yasuo Ohgaki — 2012-08-23T06:22:55+00:00

URL: https://externals.io/message/62386#62415 · In reply to: #62386

Hi,

2012/8/22 Andrew Faulds <ajf@ajf.me>:
> Um, Yasuo, have you looked at array_walk implementation and ascertained it
> is safe to change array structure while using it?
>
> Because I'm worried you're changing docs without doing so.

Simply deleting current element is safe.
It's done in everywhere in PHP. It's just like deleting elements with
zend hash.

 `array_walk()` could bite users.
If programmer sort or delete element to be processed next, it causes problem.
PHP programmer will not sort or delete next element to processed while working
with zend hash, but average PHP users do not care about internal.

I finally understand why people use `array_filter()` to delete elements and
I think we should have array_udelete() since the API is much safer than
 `array_walk()`.

Regards,

--
Yasuo Ohgaki
yohgaki@ohgaki.net

>
> --
> Sent from Samsung Mobile
> Andrew Faulds
> http://ajf.me/
>
>
>
> Yasuo Ohgaki <yohgaki@ohgaki.net> wrote:
>
>
> Hi,
>
> 2012/8/22 Levi Morrison <morrison.levi@gmail.com>:
> > […]
>
> Ok, then my commit to the doc was outstanding still.
> Old PHP was behaved badly with reference variables.
> I'll remove obsolete statement.
>
> I'll fix it later.
> Thank you.
>
> --
> Yasuo Ohgaki
> yohgaki@ohgaki.net
