Using zend_hash_find when key is of Integer type

From: Date: Thu, 03 Jul 2008 01:35:42 +0000
Subject: Using zend_hash_find when key is of Integer type
Groups: php.pecl.dev 
Request: Send a blank email to pecl-dev+get-5587@lists.php.net to get a copy of this message
Hi All, I am writing a PHP extension and over here I am trying to use zend_hash_find API to search for key in a hash. But the problem here is "my key is an integer and not *char". So this zend_hash_find will not work. There is a way by which I can do it. See the following code. for ( i = 0; i < numOpts; i++) { zend_hash_get_current_key(Z_ARRVAL_P(zval), &opt_key, &num_idx, 1); zend_hash_get_current_data(Z_ARRVAL_P(zval), (void**)&data); if (Z_TYPE_PP(data) == IS_STRING) { option_str = Z_STRVAL_PP(data); } else { option_num = Z_LVAL_PP(data); } /* further implementation. */ zend_hash_move_forward(Z_ARRVAL_P(zval)); } But this approach is inefficient as I have to iterate complete Hash to get one key-value and in my case I know the key before iterating. Is there any other better approach to do this? Regards, Ambrish Bhargava -- View this message in context: http://www.nabble.com/Using-zend_hash_find-when-key-is-of-Integer-type-tp18250168p18250168.html Sent from the Pecl - Dev mailing list archive at Nabble.com.

« previous php.pecl.dev (#5587) next »