ZEND API Question: Creating reference
| From: | Uwe Steinmann | Date: | Fri, 03 Mar 2000 11:18:43 +0000 |
| Subject: | ZEND API Question: Creating reference | ||
| Groups: | php.version4 | ||
| Request: | Send a blank email to php-version4+get-11438@lists.php.net to get a copy of this message | ||
Hi,
how do I create a reference to a variable with the Zend API?
To be more precise, here is small example:
Let's assume there is an array containing a number of elements.
I search through that array for a special element, find it and would now
like to e.g. add it as a property to an object. It must not be a copy
of that element but a reference to it. If I change later any of them both
must change.
In C this might look like the following (though it creates a copy):
lht = children->value.ht;
count = zend_hash_num_elements(lht);
zend_hash_internal_pointer_reset(lht);
for(i=0; i<count; i++) {
zval **keydata;
zend_hash_get_current_data(lht, (void **) &keydata);
if([This is the one I was looking for]) {
zend_hash_update(return_value->value.obj.properties, "root",
strlen("root")+1, (void *) &(*keydata), sizeof(zval *), NULL);
}
zend_hash_move_forward(lht);
}
I tried zend_hash_update_ptr instead but this didn't work either.
If fiddeled with refcount and is_ref, also without success.
How else could this be done?
Uwe
--
Uwe.Steinmann@fernuni-hagen.de
Tel: +2331 987 4528 Fax: +2331 987 375