note 87666 added to language.types.resource
| From: | wetmonkey__ at at __gmail dot com | Date: | Tue, 16 Dec 2008 00:17:16 +0000 |
| Subject: | note 87666 added to language.types.resource | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-148198@lists.php.net to get a copy of this message | ||
Resources are commonly used to iterate through a mysql or file handle.
example
while($row = mysql_fetch_row($resource)){
echo $row[0] ;
}
It's possible to fake this treatment.
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.
----
Server IP: 209.41.74.194
Probable Submitter: 70.191.164.15
----
Manual Page -- http://www.php.net/manual/en/language.types.resource.php
Edit -- https://master.php.net/note/edit/87666
Del: integrated -- https://master.php.net/note/delete/87666/integrated
Del: useless -- https://master.php.net/note/delete/87666/useless
Del: bad code -- https://master.php.net/note/delete/87666/bad+code
Del: spam -- https://master.php.net/note/delete/87666/spam
Del: non-english -- https://master.php.net/note/delete/87666/non-english
Del: in docs -- https://master.php.net/note/delete/87666/in+docs
Del: other reasons-- https://master.php.net/note/delete/87666
Reject -- https://master.php.net/note/reject/87666
Search -- https://master.php.net/manage/user-notes.php