Hi,

I am wondering is this is normal behaviour. I have an array:

 array(2) {
      [127443] => string(8) "12345678"
      [1270236] => string(8) "12345678"
      [1270656] => string(8) "12345678"
    }
I've created Zend_Paginator object with Zend_Pagination_Adapter_Array and I
am iterating this object.

When I iterate it like:

foreach($paginator as $key => $value){
echo $key;
echo $value;
}

$key values are lost. I've checked source of the
Zend_Pagination_Adapter_Array, function getItems():

/**
     * Returns an array of items for a page.
     *
     * @param  integer $offset Page offset
     * @param  integer $itemCountPerPage Number of items per page
     * @return array
     */
    public function getItems($offset, $itemCountPerPage)
    {
        return array_slice($this->_array, $offset, $itemCountPerPage);
    }

Function array_slice could take fourth parameter: $preserve_keys and it is
not. So, the question is, is this behaviour per design or it is a bug?

Regards,
Damir
-- 
View this message in context: 
http://zend-framework-community.634137.n4.nabble.com/Zend-Pagination-Adapter-Array-usage-questions-tp2321181p2321181.html
Sent from the Zend Framework mailing list archive at Nabble.com.

Reply via email to