note 68434 added to function.next

From: Date: Wed, 26 Jul 2006 23:19:11 +0000
Subject: note 68434 added to function.next
Groups: php.notes 
Request: Send a blank email to php-notes+get-115231@lists.php.net to get a copy of this message
I see some questions like "how can I know if an array has a next value without changing its internal pointer" and some pretty complicated responses that DO work mind you and in some cases you'll need them... But suppose you just need a different action within a foreach loop when reaching the final item: (it won't be usefull in every situation, but in most it will) $numOfItems = count($someArray); $counter = 0; foreach ($someArray as $key => value){ $counter += 1; if ($counter <> $numOfItems){ //here all next items exist } else { //final item } } ---- Server IP: 193.190.198.20 Probable Submitter: 84.197.36.189 ---- X-Spam-Status: No, hits=3.1 required=5.0 tests=DATE_MISSING,FROM_NO_LOWER autolearn=no version=2.64 ---- Manual Page -- http://www.php.net/manual/en/function.next.php Edit -- http://master.php.net/note/edit/68434 Del: integrated -- http://master.php.net/note/delete/68434/integrated Del: useless -- http://master.php.net/note/delete/68434/useless Del: bad code -- http://master.php.net/note/delete/68434/bad+code Del: spam -- http://master.php.net/note/delete/68434/spam Del: non-english -- http://master.php.net/note/delete/68434/non-english Del: in docs -- http://master.php.net/note/delete/68434/in+docs Del: other reasons-- http://master.php.net/note/delete/68434 Reject -- http://master.php.net/note/reject/68434 Search -- http://master.php.net/manage/user-notes.php

« previous php.notes (#115231) next »