Re: creating an array in the extension
| From: | Andrei Zmievski | Date: | Wed, 16 Aug 2000 13:24:56 +0000 |
| Subject: | Re: creating an array in the extension | ||
| References: | 1 | Groups: | php.dev |
| Request: | Send a blank email to php-dev+get-29127@lists.php.net to get a copy of this message | ||
On Tue, 15 Aug 2000, Gustavo Badauy wrote:
> PHP_FUNCTION(cs_testfunction)
> {
> int result;
> zval *data;
> zval ret_array;
>
> result = zend_hash_exists (EG(active_symbol_table), "myvar",
> strlen("myvar") + 1 );
> // test if it exists
> result = array_init (&ret_array);
> // test if was successfull
>
> // copied from appendix B of PHP3 Manual
> result = zend_hash_update(EG(active_symbol_table),
> "myarray", strlen("myarray") +1,
> &ret_array, sizeof(zval), NULL);
>
> MAKE_STD_ZVAL(data);
> data->type = IS_LONG;
> data->value.lval = 1234;
> ZEND_SET_SYMBOL (EG(active_symbol_table),"myvar",data);
>
>
> }
Try this:
zval *ret_array;
MAKE_STD_ZVAL(ret_array);
array_init(ret_array);
And then do your zend_hash_update().
-Andrei
As I was going up the stair, I met a man who wasn't there.
He wasn't there again today. I wish, I wish he'd stay away.
-Hughes Mearns