Re: [Fwd: Re: [PHP] Howto return multidimensional arrays from a PHP module]

From: Date: Mon, 05 Feb 2001 19:06:50 +0000
Subject: Re: [Fwd: Re: [PHP] Howto return multidimensional arrays from a PHP module]
References: 1  Groups: php.dev 
Request: Send a blank email to php-dev+get-45802@lists.php.net to get a copy of this message
I had the same problem. This is, how I managed to do this: extern "C" int fun1(pval** array) { //this is in c++ //here you generate subarrays - alements are added to the parameter array //this generates an array of strings ... int count=xxxx; for (int i=0;i<count;i++) { char* str=estrdup("Array element"); zval* arr_el; MAKE_STD_ZVAL(arr_el); ZVAL_STRING(arr_el,str,0); zend_hash_next_index_insert ((*array)->value.ht,&arr_el,sizeof(zval**),NULL); } return count; } /* {{{ proto array fun2() //this is in standard c */ PHP_FUNCTION(konf) { //here you generate array with array elements ... if (array_init(return_value) == FAILURE) { RETURN_FALSE; } for (...) { zval* arr_element; MAKE_STD_ZVAL(arr_element); if (array_init(arr_element) == FAILURE) { RETURN_FALSE; } zend_hash_next_index_insert( return_value->value.ht, (void*)&arr_element,sizeof(zval*), NULL); fun1(&arr_element); <----- now add elements } } /* }}} */ It was something like that .... It generates two-dimensional array. Ouuuff... It took me much of time to "develope" this... And no guarantees ...

« previous php.dev (#45802) next »