Internal API: Getting array key and value

16 views
Skip to first unread message

hdo...@gmail.com

unread,
Oct 22, 2012, 10:37:23 AM10/22/12
to phalcon-...@googlegroups.com
Hello,

I need a solution to get array key and value pair for first array item only. The array will be like array('key' => 'value'). If there is other items, they will be skipped.

I understand how to get key/value pairs with internal foreach cycles. Should I code with same approach and count and break the cycle after 1st item?

There would be nice to have helper functions like these ones:

phalcon_array_reset(zval *array) - resets the cursor of an array
phalcon_array_current(zval *array) - gets current item (key/value pair) of an array
phalcon_array_next/prev
phalcon_array_first/last (get first or last element of an array?)

Like PHP's reset/next/prev/current functions.

Thanks.

Hidayet Dogan

Andres-Gutierrez

unread,
Oct 22, 2012, 12:16:22 PM10/22/12
to hdo...@gmail.com, phalcon-...@googlegroups.com

hdo...@gmail.com

unread,
Oct 22, 2012, 4:52:07 PM10/22/12
to phalcon-...@googlegroups.com, hdo...@gmail.com, andres.g...@phalconphp.com
I still couldn't find how to get key and value, or I'm blind :)

I think "rows" is one element array but I need to reach it's key and value with different variables.

Anyway, I don't need it anymore :D 
Reply all
Reply to author
Forward
0 new messages