note 87666 deleted from language.types.resource by googleguy

From: Date: Wed, 16 Jan 2013 05:30:21 +0000
Subject: note 87666 deleted from language.types.resource by googleguy
References: 1  Groups: php.notes 
Request: Send a blank email to php-notes+get-193092@lists.php.net to get a copy of this message
Note Submitter: wetmonkey__ at at __gmail dot com ---- Resources are commonly used to iterate through a mysql or file handle. example <?php while($row = mysql_fetch_row($resource)){ echo $row[0] ; } ?> It's possible to fake this treatment. <?php class fakewhile{ public $arrayCount; public $arrayCounter; function setArrValues(){ $this->arrValues = array(0 =>array("apple","artichoke","apricot"),1 => array("bears","dogs","cats")); $this->arrayCounter = 0; $this->arrayCount = count($this->arrValues); } function outputValues(){ /* * Anything until the if statement is evaluted one more * time then the array count value */ $arrayInfo = $this->arrValues; $arrCounter = $this->arrayCounter; if($arrCounter > $this->arrayCount){ return false; } $endCounter = $arrCounter+1; $this->arrayCounter = $endCounter; return $arrayInfo[$arrCounter]; } } $fw = new fakewhile(); $fw->setArrValues(); while($row = $fw->outputValues()){ print_r($row); } ?> Hopefully will get someone started on completing a complete application.

« previous php.notes (#193092) next »