note 118825 added to class.iteratoriterator

From: Date: Fri, 12 Feb 2016 01:53:46 +0000
Subject: note 118825 added to class.iteratoriterator
Groups: php.notes 
Request: Send a blank email to php-notes+get-204923@lists.php.net to get a copy of this message
Little note for anyone that wants to emulate the behavior of foreach as close as possible in order to work with somewhat picky Traversable objects, without using foreach: - Before starting the iteration, rewind() is called. - For every iteration, the following methods are called on the iterator: - valid() - current() - key() - next() Sounds like a silly thing to do put this way, but in my use case I needed to convert a Traversable database result cursor into a procedural-style cursor (hasNext + fetchArray) for backward compatibility, and the driver required every function to be called in the appropriate order. ---- Server IP: 72.52.91.14 Probable Submitter: 70.49.215.47 ---- Manual Page -- http://php.net/manual/en/class.iteratoriterator.php Edit -- https://master.php.net/note/edit/118825 Del: integrated -- https://master.php.net/note/delete/118825/integrated Del: useless -- https://master.php.net/note/delete/118825/useless Del: bad code -- https://master.php.net/note/delete/118825/bad+code Del: spam -- https://master.php.net/note/delete/118825/spam Del: non-english -- https://master.php.net/note/delete/118825/non-english Del: in docs -- https://master.php.net/note/delete/118825/in+docs Del: other reasons-- https://master.php.net/note/delete/118825 Reject -- https://master.php.net/note/reject/118825 Search -- https://master.php.net/manage/user-notes.php

« previous php.notes (#204923) next »