Re: [PHP-DEV] Thoughts on adopting Python's for/foreach else construct.

2020-02-25 Thread Nikita Popov
On Tue, Feb 25, 2020 at 8:19 PM Michael Morris wrote: > I don't remember if this has been discussed before, but I've been working > with some listing code and wishing for a cleaner way to do this > >if (count($a) === 0) { > // code for no results > } > else { > foreach( $a as $key

Re: [PHP-DEV] Thoughts on adopting Python's for/foreach else construct.

2020-02-25 Thread Christian Schneider
Am 25.02.2020 um 20:18 schrieb Michael Morris : > How difficult would it be to make the following work in the interpreter? > > foreach($a as $key => $value) { >// code for iteration > } > else { >// code for no results > } > ?> > > The code of the else clause executes if the foreach

[PHP-DEV] Thoughts on adopting Python's for/foreach else construct.

2020-02-25 Thread Michael Morris
I don't remember if this has been discussed before, but I've been working with some listing code and wishing for a cleaner way to do this $value) { // code for iteration } } ?> How difficult would it be to make the following work in the interpreter? $value) { // code for iterat