note 32225 added to control-structures.foreach
| From: | Storm at rack1 dot php dot net | Date: | Tue, 20 May 2003 23:21:31 +0000 |
| Subject: | note 32225 added to control-structures.foreach | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-48696@lists.php.net to get a copy of this message | ||
Using this for a class CAN be useful if you want to destroy vars inside the class from inside the
class...
class ... {
// vars...
function destroy() {
foreach ($this as $var=>$val) {
if ($var != 'Some var we want to keep') {
unset($this->{$var});
}
}
}
}
It works great when you want to destroy all of the class variables of a database class except for
the connection status so that you can still use that status for other parts of your external
script...
I guess ;)
----
Manual Page -- http://www.php.net/manual/en/control-structures.foreach.php
Edit Note -- http://master.php.net/manage/user-notes.php?action=edit+32225
Delete Note -- http://master.php.net/manage/user-notes.php?action=delete+32225&report=yes
Reject Note -- http://master.php.net/manage/user-notes.php?action=reject+32225&report=yes