note 101317 modified in control-structures.foreach by danbrown

From: Date: Thu, 09 Dec 2010 15:20:38 +0000
Subject: note 101317 modified in control-structures.foreach by danbrown
References: 1  Groups: php.notes 
Request: Send a blank email to php-notes+get-174748@lists.php.net to get a copy of this message
Just found a way without a counter handling last element in a foreach : <?php $foo = ($current_key == count($array)-1) ? "last element" : "any other element"; ?> --was-- Just found a way without a counter handling last element in a foreach : $foo = ($current_key == count($array)-1) ? "last element" : "any other element"; http://php.net/manual/en/control-structures.foreach.php

« previous php.notes (#174748) next »