Re: Return array in parameter from extension

From: Date: Tue, 24 Sep 2002 16:58:57 +0000
Subject: Re: Return array in parameter from extension
References: 1  Groups: php.dev 
Request: Send a blank email to php-dev+get-88564@lists.php.net to get a copy of this message
Try this: /*** array your_ext_func() ***/ ZEND_FUNCTION(your_ext_func) { zval *val_ret, *val_str; char *output; int ret; output = (char *)emalloc( 100 ); <some code to set output and ret> array_init(return_value); MAKE_STD_ZVAL(val_ret); MAKE_STD_ZVAL(val_str); ZVAL_LONG(val_ret, ret ); ZVAL_STRING(val_str, output, 0); /*** return_value is an array, [0] is value ret, [1] is string output ***/ zend_hash_next_index_insert( HASH_OF(return_value), &val_ret, sizeof(zval *), NULL ); zend_hash_next_index_insert( HASH_OF(return_value), &val_str, sizeof(zval *), NULL ); } In your php file do this: list($ret,$str) = your_ext_func(); Just a simple example, edit as needed. Brian At 6:21 PM +0200 9/24/02, Ole Stakemann wrote:
How do I do that in an extension? I want to adhere to the recommendation that allow_call_time_pass_reference should be off.


« previous php.dev (#88564) next »