note 73075 added to function.next

From: Date: Thu, 08 Feb 2007 05:08:16 +0000
Subject: note 73075 added to function.next
Groups: php.notes 
Request: Send a blank email to php-notes+get-123106@lists.php.net to get a copy of this message
There ought to be some sort of peek function, like an i/o stream in C/C++... I've looked through the documentation here, but I haven't found anything. A simple implementation: <?php function peek(&$array) { //Peek to next element on array stack $ret=next($array); prev($array); return $ret; } ?> I'm not sure if there should be any more references with $ret (for efficiency). I'm using this to see if it's the last element on the stack. <?php foreach ($array as $a) { ... if (peek($array)!==false) ...; } ?> Useful for extended implode-type functionality. ---- Server IP: 69.147.83.197 Probable Submitter: 74.192.112.67 ---- Manual Page -- http://www.php.net/manual/en/function.next.php Edit -- https://master.php.net/note/edit/73075 Del: integrated -- https://master.php.net/note/delete/73075/integrated Del: useless -- https://master.php.net/note/delete/73075/useless Del: bad code -- https://master.php.net/note/delete/73075/bad+code Del: spam -- https://master.php.net/note/delete/73075/spam Del: non-english -- https://master.php.net/note/delete/73075/non-english Del: in docs -- https://master.php.net/note/delete/73075/in+docs Del: other reasons-- https://master.php.net/note/delete/73075 Reject -- https://master.php.net/note/reject/73075 Search -- https://master.php.net/manage/user-notes.php

« previous php.notes (#123106) next »