Get object from arraycollection
Posted
by
Nll
on Stack Overflow
See other posts from Stack Overflow
or by Nll
Published on 2012-09-29T21:10:55Z
Indexed on
2012/09/29
21:37 UTC
Read the original article
Hit count: 240
I have a problem about to get an object from arraycollection of objects with Id,so I do :
protected $_rootObject;
public function __construct(myClasse $rootObject)
{
$this->_rootObject= $rootObject;
}
public function getObjectById($id)
{
$value = null;
foreach($this->_rootObject as $root)
{
if ($id == $root->getId())
{
$value = $root;
break;
}
}
return $value;
}
Then the function return "NULL" so it's dosn't work...
© Stack Overflow or respective owner