Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:99874 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 35987 invoked from network); 15 Jul 2017 08:58:01 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 15 Jul 2017 08:58:01 -0000 X-Host-Fingerprint: 62.180.109.77 unknown Received: from [62.180.109.77] ([62.180.109.77:26912] helo=localhost.localdomain) by pb1.pair.com (ecelerity 2.1.1.9-wez r(12769M)) with ESMTP id 3E/33-01782-719D9695 for ; Sat, 15 Jul 2017 04:57:59 -0400 Message-ID: <3E.33.01782.719D9695@pb1.pair.com> To: internals@lists.php.net References: Date: Sat, 15 Jul 2017 10:57:56 +0200 User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.13; rv:45.0) Gecko/20100101 Thunderbird/45.2.0 MIME-Version: 1.0 In-Reply-To: Content-Type: text/plain; charset=utf-8; format=flowed Content-Transfer-Encoding: 7bit X-Posted-By: 62.180.109.77 Subject: Re: [PHP-DEV] Allow else after loop structures for,foreach and while? From: gmblar@gmail.com (Andreas Treichel) Hi Michael, > Allow else blocks to follow iteration blocks. The else block is executed > if no iteration occurs for any reason. I also thought it would been a good idea, but most of the time i need a wrapper in the output like this: if($items) { echo '
    '; foreach($items as $item) { echo '
  • ', $item, '
  • '; } echo '
' } And this may change the behavior of: if($result) foreach($items as $item) var_dump($item); else echo 'Nothing'; from: if($result) { foreach($items as $item) { var_dump($item); } } else { echo 'Nothing'; } to: if($result) { foreach($items as $item) { var_dump($item); } else { echo 'Nothing'; } } I believe this change is only possible (useful or not) if the curly braces are always required.