RE: [PHP-DEV] how-to get array[0] and array["name"] to actually r eference only 1 value?
| From: | Marc Boeren | Date: | Mon, 12 Feb 2001 09:25:17 +0000 |
| Subject: | RE: [PHP-DEV] how-to get array[0] and array["name"] to actually r eference only 1 value? | ||
| Groups: | php.dev | ||
| Request: | Send a blank email to php-dev+get-46413@lists.php.net to get a copy of this message | ||
>not bound together in any way. You may be able to accomplish what you
>desire by using references. (See the manual section on references for more
>information.
> ie. $q->data[0]["id"] =& $q->data[0][0];
After looking for references in the php-code, I found something that seems
to work ok (zend_assign_to_variable_reference):
zval *dummy, *value, **x_ptr, **y_ptr;
MAKE_STD_ZVAL(value);
ZVAL_LONG(value, 10);
ALLOC_ZVAL(dummy);
INIT_ZVAL(*dummy);
zend_hash_update(return_value->value.obj.properties, "x", sizeof("x"),
&value, sizeof(zval *), (void **) &x_ptr);
zend_hash_update(return_value->value.obj.properties, "y", sizeof("y"),
&dummy, sizeof(zval *), (void **) &y_ptr);
zend_assign_to_variable_reference(NULL, y_ptr, x_ptr, NULL ELS_CC);
This leads me to another question: how do I obtain the x_ptr (from the
example) if the zend_hash_update was done elsewhere and no ptr was passed
then???
zend_hash_update(return_value->value.obj.properties, "x", sizeof("x"),
&value, sizeof(zval *), NULL);
[...]
// How do I get the x_ptr ???
zend_hash_update(return_value->value.obj.properties, "y", sizeof("y"),
&dummy, sizeof(zval *), (void **) &y_ptr);
zend_assign_to_variable_reference(NULL, y_ptr, x_ptr, NULL ELS_CC);
Cheerio, Marc.