Re: [RFC] Cast in foreach
| From: | Chris Riley | Date: | Fri, 22 Feb 2019 14:26:53 +0000 |
| Subject: | Re: [RFC] Cast in foreach | ||
| References: | 1 | Groups: | php.internals |
| Request: | Send a blank email to internals+get-104507@lists.php.net to get a copy of this message | ||
Cast would work for both key and value, although I think the instances
where you need to cast a key will be fewer.
On Thu, Feb 21, 2019, 15:08 Legale.legale <legale.legale@gmail.com> wrote:
> what about:
>
> foreach($array as $i=>$v) {}
>
> ?On Feb 21, 2019 13:15, Chris Riley <t.carnage@gmail.com> wrote:
> >
> > Hi internals,
> >
> > I'd like to propose opening an rfc to make the following syntax legal:
> >
> > foreach($array as (int) $i) {}
> >
> > Which would be functionally equivalent to
> >
> > foreach($array as $i) {
> > $i=(int) $i;
> > }
> >
> > Thoughts? Feedback?
> > ~C
>