when I go through the documentation of zend framework 2, i just found methods like
getOffset($key)
and offsetExists($key)
. But for both we have to specify the keys.
My question is, Is there any method or any other way for retrieving all the keys or all the data associated with a container without specifying the keys.
Asked
Active
Viewed 469 times
1

akond
- 15,865
- 4
- 35
- 55

user1425212
- 11
- 2
2 Answers
1
The container is just an ArrayObject and implements getIterator, so you can simply do
foreach ($container as $key => $value)
{
var_dump($key);
}

akond
- 15,865
- 4
- 35
- 55
1
Another option without a loop is to get keys or values from getArrayCopy()
$values = $container->getArrayCopy();
var_dump($values);
$keys = array_keys($values);
var_dump($keys);

Crisp
- 11,417
- 3
- 38
- 41