note 106561 added to function.next
| From: | bluexpres at osu1 dot php dot net | Date: | Fri, 18 Nov 2011 16:54:55 +0000 |
| Subject: | note 106561 added to function.next | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-184564@lists.php.net to get a copy of this message | ||
is a recursive one.if current = last, return first
class Steps {
private $all;
private $count;
private $curr;
private $checknex;
public function __construct () {
$this->count = 0;
}
public function add ($step) {
$this->count++;
$this->all[$this->count] = $step;
}
public function setCurrent ($step) {
reset($this->all);
for ($i=1; $i<=$this->count; $i++) {
if ($this->all[$i]==$step) break;
next($this->all);
}
$this->curr = current($this->all);
}
public function getCurrent () {
return $this->curr;
}
public function getNext () {
self::setCurrent($this->curr);
$this->nex = next($this->all);
if($this->checknex == "") return reset($this->all); else return
$this->checknex;
}
}
$steps = new Steps();
$steps->add('1');
$steps->add('2');
$steps->add('3');
$steps->add('4');
$steps->add('5');
$steps->add('6');
$steps->setCurrent('6');
echo $steps->getCurrent()."<br />";
echo $steps->getNext()."<br />";
----
Server IP: 69.147.83.197
Probable Submitter: 88.224.58.53
----
Manual Page -- http://www.php.net/manual/en/function.next.php
Edit -- https://master.php.net/note/edit/106561
Del: integrated -- https://master.php.net/note/delete/106561/integrated
Del: useless -- https://master.php.net/note/delete/106561/useless
Del: bad code -- https://master.php.net/note/delete/106561/bad+code
Del: spam -- https://master.php.net/note/delete/106561/spam
Del: non-english -- https://master.php.net/note/delete/106561/non-english
Del: in docs -- https://master.php.net/note/delete/106561/in+docs
Del: other reasons-- https://master.php.net/note/delete/106561
Reject -- https://master.php.net/note/reject/106561
Search -- https://master.php.net/manage/user-notes.php