From b918f2ea7ba466d52986b553c9417a295a5f7b8d Mon Sep 17 00:00:00 2001 From: Derick Rethans Date: Thu, 30 Jun 2011 11:25:57 +0100 Subject: [PATCH] Implemented TWIG_RETURN_ARRAY_ELEMENT. --- twig.c | 11 ++++++++++- 1 files changed, 10 insertions(+), 1 deletions(-) diff --git a/twig.c b/twig.c index a072ca3..f365ab7 100644 --- a/twig.c +++ b/twig.c @@ -154,9 +154,18 @@ int TWIG_ISSET_ARRAY_ELEMENT(zval *array, zval *item) return 0; } -zval *TWIG_RETURN_ARRAY_ELEMENT(zval *object, zval *item) +zval *TWIG_RETURN_ARRAY_ELEMENT(zval *array, zval *key) { + void *dummy; + if (Z_TYPE_P(array) != IS_ARRAY) { + return NULL; + } + convert_to_string(key); + if (zend_hash_find(Z_ARRVAL_P(array), Z_STRVAL_P(key), Z_STRLEN_P(key) + 1, &dummy) == SUCCESS) { + return dummy; + } + return NULL; } zval *TWIG_PROPERTY(zval *object, char *propname) -- 1.7.2.5