note 102348 added to class.arrayobject

From: Date: Wed, 09 Feb 2011 23:15:58 +0000
Subject: note 102348 added to class.arrayobject
Groups: php.notes 
Request: Send a blank email to php-notes+get-176830@lists.php.net to get a copy of this message
The note above posted by tony at tonyandcarol dot com could be improved adding the methods: function getCollection() { return $this->data; } function exists($_id) { if($_thisObject = $this->data->offSetExists($_id)) return true; else return false; } The first one might be useful to call an iterator: $iterator = $myCollection->getCollection()->getIterator(); while($iterator->valid()) { echo $iterator->key() . ' => ' . $iterator->current()->getObject() . "\n"; $iterator->next(); } The second one might be useful to control the function addObject($_id, $_object). if($myCollection->exists($key)) $myCollection->addObject($key,$myCollection->getObject($key)+1); else $myCollection->addObject($key, 1); ---- Server IP: 69.147.83.197 Probable Submitter: 188.81.84.169 ---- Manual Page -- http://www.php.net/manual/en/class.arrayobject.php Edit -- https://master.php.net/note/edit/102348 Del: integrated -- https://master.php.net/note/delete/102348/integrated Del: useless -- https://master.php.net/note/delete/102348/useless Del: bad code -- https://master.php.net/note/delete/102348/bad+code Del: spam -- https://master.php.net/note/delete/102348/spam Del: non-english -- https://master.php.net/note/delete/102348/non-english Del: in docs -- https://master.php.net/note/delete/102348/in+docs Del: other reasons-- https://master.php.net/note/delete/102348 Reject -- https://master.php.net/note/reject/102348 Search -- https://master.php.net/manage/user-notes.php

« previous php.notes (#176830) next »