> Well, I think you might be able to help me then. I want to retrieve an
> array and walk throught it. Should be pretty simple, right?
Think of which PHP functions do this and go have a look. Basically think
of how you do it in PHP at the low level. You would do something like
this:
reset($arr);
while($val=current($arr)) {
$key = key($arr);
... do something with $key and $val ...
next($arr);
}
Now, obviously this has a slight problem of $val evaluating to false, but
it is more to explain the steps.
Now here is the C equivalent:
zval **arr,**val;
char *key;
ulong num_key;
HashTable *target_hash;
HashPosition pos;
target_hash = HASH_OF($arr);
zend_hash_internal_pointer_reset_ex(target_hash, &pos);
while(zend_hash_get_current_data_ex(target_hash, (void **)&val, &pos) == SUCCESS) {
type = zend_hash_get_current_key_ex(target_hash, &string_key, &str_key_len,
&num_key, 0, &pos);
// type will be HASH_KEY_IS_STRING for a string key, and string_key/str_key_len
are set
// or type will be HASH_KEY_IS_LONG and num_key will be set
// Now you have a normal zval** with the value and the key in either of string_key
or num_key
zend_hash_move_forward_ex(target_hash, &pos);
}
That's all.
-Rasmus
--
PHP Development Mailing List <http://www.php.net/>
To unsubscribe, visit: http://www.php.net/unsub.php