Re: How to return array

From: Date: Thu, 25 Dec 2003 07:35:35 +0000
Subject: Re: How to return array
References: 1  Groups: php.pecl.dev 
Request: Send a blank email to pecl-dev+get-274@lists.php.net to get a copy of this message
On Thursday 25 December 2003 03:20 am, Ptker wrote: > I need return an array like this: > $arr['test'][0]['red']=0; > $arr['test'][1]['red']=1; > Why the following codes coun'd work fine? Try it without the two efree statements at the bottom. > PHP_FUNCTION(test) > { > zval *z_tmp1=NULL, *z_tmp2=NULL; > int i=0; > MAKE_STD_ZVAL(z_tmp2); > array_init(return_value); > array_init(z_tmp2); > for (i = 0; i < 2; i++) { > MAKE_STD_ZVAL(z_tmp1); > array_init(z_tmp1); > add_assoc_long(z_tmp1, "red", i); > add_index_zval(z_tmp2, i, z_tmp1); > } > add_assoc_zval(return_value, "test", z_tmp2); > efree(z_tmp1); > efree(z_tmp2); > } -- Evan Nemerson evan@coeus-group.com http://coeusgroup.com/en -- "Truth, like gold, is to be obtained not by its growth, but by washing away from it all that is not gold. " -Leo Nikolaevich Tolstoy

« previous php.pecl.dev (#274) next »