note 66065 added to function.next

From: Date: Sat, 13 May 2006 15:48:22 +0000
Subject: note 66065 added to function.next
Groups: php.notes 
Request: Send a blank email to php-notes+get-111236@lists.php.net to get a copy of this message
this may be handy and i didnt know where else to post it.. i need a simple function to cycle through an array i eventually made it into a class so i could have multiple cycles.. if you like it or find it usefull please email me and let me know class Cycle { var $position; var $dataArray; var $dataArrayCount; function Cycle() { $this->dataArray = func_get_args(); $this->dataArrayCount = count($this->dataArray); } function Display() { $this->position = (!isset($this->position) || $this->position >= ($this->dataArrayCount - 1)) ? 0 : $this->position += 1; return $this->dataArray[$this->position]; } } $bgColor = new Cycle('#000000', '#FFFFFF', '#FF0000'); echo $bgcolor->Display(); //returns #000000 echo $bgcolor->Display(); //returns #FFFFFF echo $bgcolor->Display(); //returns #FF0000 echo $bgcolor->Display(); //returns #000000 ---- Server IP: 216.194.113.175 Probable Submitter: 66.177.211.170 ---- 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/66065 Del: integrated -- http://master.php.net/note/delete/66065/integrated Del: useless -- http://master.php.net/note/delete/66065/useless Del: bad code -- http://master.php.net/note/delete/66065/bad+code Del: spam -- http://master.php.net/note/delete/66065/spam Del: non-english -- http://master.php.net/note/delete/66065/non-english Del: in docs -- http://master.php.net/note/delete/66065/in+docs Del: other reasons-- http://master.php.net/note/delete/66065 Reject -- http://master.php.net/note/reject/66065 Search -- http://master.php.net/manage/user-notes.php

« previous php.notes (#111236) next »